babylon.d.txt 2.8 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Color3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1821. /**
  1822. * Unproject from screen space to object space
  1823. * @param source defines the screen space Vector3 to use
  1824. * @param viewportWidth defines the current width of the viewport
  1825. * @param viewportHeight defines the current height of the viewport
  1826. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1827. * @param transform defines the transform (view x projection) matrix to use
  1828. * @returns the new Vector3
  1829. */
  1830. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1831. /**
  1832. * Unproject from screen space to object space
  1833. * @param source defines the screen space Vector3 to use
  1834. * @param viewportWidth defines the current width of the viewport
  1835. * @param viewportHeight defines the current height of the viewport
  1836. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1837. * @param view defines the view matrix to use
  1838. * @param projection defines the projection matrix to use
  1839. * @returns the new Vector3
  1840. */
  1841. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1842. /**
  1843. * Unproject from screen space to object space
  1844. * @param source defines the screen space Vector3 to use
  1845. * @param viewportWidth defines the current width of the viewport
  1846. * @param viewportHeight defines the current height of the viewport
  1847. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1848. * @param view defines the view matrix to use
  1849. * @param projection defines the projection matrix to use
  1850. * @param result defines the Vector3 where to store the result
  1851. */
  1852. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1853. /**
  1854. * Unproject from screen space to object space
  1855. * @param sourceX defines the screen space x coordinate to use
  1856. * @param sourceY defines the screen space y coordinate to use
  1857. * @param sourceZ defines the screen space z coordinate to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @param result defines the Vector3 where to store the result
  1864. */
  1865. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1866. /**
  1867. * Gets the minimal coordinate values between two Vector3
  1868. * @param left defines the first operand
  1869. * @param right defines the second operand
  1870. * @returns the new Vector3
  1871. */
  1872. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1873. /**
  1874. * Gets the maximal coordinate values between two Vector3
  1875. * @param left defines the first operand
  1876. * @param right defines the second operand
  1877. * @returns the new Vector3
  1878. */
  1879. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1880. /**
  1881. * Returns the distance between the vectors "value1" and "value2"
  1882. * @param value1 defines the first operand
  1883. * @param value2 defines the second operand
  1884. * @returns the distance
  1885. */
  1886. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1887. /**
  1888. * Returns the squared distance between the vectors "value1" and "value2"
  1889. * @param value1 defines the first operand
  1890. * @param value2 defines the second operand
  1891. * @returns the squared distance
  1892. */
  1893. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1894. /**
  1895. * Returns a new Vector3 located at the center between "value1" and "value2"
  1896. * @param value1 defines the first operand
  1897. * @param value2 defines the second operand
  1898. * @returns the new Vector3
  1899. */
  1900. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1901. /**
  1902. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1903. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1904. * to something in order to rotate it from its local system to the given target system
  1905. * Note: axis1, axis2 and axis3 are normalized during this operation
  1906. * @param axis1 defines the first axis
  1907. * @param axis2 defines the second axis
  1908. * @param axis3 defines the third axis
  1909. * @returns a new Vector3
  1910. */
  1911. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1912. /**
  1913. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1914. * @param axis1 defines the first axis
  1915. * @param axis2 defines the second axis
  1916. * @param axis3 defines the third axis
  1917. * @param ref defines the Vector3 where to store the result
  1918. */
  1919. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1920. }
  1921. /**
  1922. * Vector4 class created for EulerAngle class conversion to Quaternion
  1923. */
  1924. export class Vector4 {
  1925. /** x value of the vector */
  1926. x: number;
  1927. /** y value of the vector */
  1928. y: number;
  1929. /** z value of the vector */
  1930. z: number;
  1931. /** w value of the vector */
  1932. w: number;
  1933. /**
  1934. * Creates a Vector4 object from the given floats.
  1935. * @param x x value of the vector
  1936. * @param y y value of the vector
  1937. * @param z z value of the vector
  1938. * @param w w value of the vector
  1939. */
  1940. constructor(
  1941. /** x value of the vector */
  1942. x: number,
  1943. /** y value of the vector */
  1944. y: number,
  1945. /** z value of the vector */
  1946. z: number,
  1947. /** w value of the vector */
  1948. w: number);
  1949. /**
  1950. * Returns the string with the Vector4 coordinates.
  1951. * @returns a string containing all the vector values
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Returns the string "Vector4".
  1956. * @returns "Vector4"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Returns the Vector4 hash code.
  1961. * @returns a unique hash code
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1966. * @returns the resulting array
  1967. */
  1968. asArray(): number[];
  1969. /**
  1970. * Populates the given array from the given index with the Vector4 coordinates.
  1971. * @param array array to populate
  1972. * @param index index of the array to start at (default: 0)
  1973. * @returns the Vector4.
  1974. */
  1975. toArray(array: FloatArray, index?: number): Vector4;
  1976. /**
  1977. * Adds the given vector to the current Vector4.
  1978. * @param otherVector the vector to add
  1979. * @returns the updated Vector4.
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1982. /**
  1983. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1984. * @param otherVector the vector to add
  1985. * @returns the resulting vector
  1986. */
  1987. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1988. /**
  1989. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1990. * @param otherVector the vector to add
  1991. * @param result the vector to store the result
  1992. * @returns the current Vector4.
  1993. */
  1994. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1995. /**
  1996. * Subtract in place the given vector from the current Vector4.
  1997. * @param otherVector the vector to subtract
  1998. * @returns the updated Vector4.
  1999. */
  2000. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2001. /**
  2002. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2003. * @param otherVector the vector to add
  2004. * @returns the new vector with the result
  2005. */
  2006. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2007. /**
  2008. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2009. * @param otherVector the vector to subtract
  2010. * @param result the vector to store the result
  2011. * @returns the current Vector4.
  2012. */
  2013. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2014. /**
  2015. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2016. */
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. * @param x value to subtract
  2020. * @param y value to subtract
  2021. * @param z value to subtract
  2022. * @param w value to subtract
  2023. * @returns new vector containing the result
  2024. */
  2025. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2026. /**
  2027. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2028. * @param x value to subtract
  2029. * @param y value to subtract
  2030. * @param z value to subtract
  2031. * @param w value to subtract
  2032. * @param result the vector to store the result in
  2033. * @returns the current Vector4.
  2034. */
  2035. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2036. /**
  2037. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2038. * @returns a new vector with the negated values
  2039. */
  2040. negate(): Vector4;
  2041. /**
  2042. * Multiplies the current Vector4 coordinates by scale (float).
  2043. * @param scale the number to scale with
  2044. * @returns the updated Vector4.
  2045. */
  2046. scaleInPlace(scale: number): Vector4;
  2047. /**
  2048. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2049. * @param scale the number to scale with
  2050. * @returns a new vector with the result
  2051. */
  2052. scale(scale: number): Vector4;
  2053. /**
  2054. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2055. * @param scale the number to scale with
  2056. * @param result a vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. scaleToRef(scale: number, result: Vector4): Vector4;
  2060. /**
  2061. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2062. * @param scale defines the scale factor
  2063. * @param result defines the Vector4 object where to store the result
  2064. * @returns the unmodified current Vector4
  2065. */
  2066. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2067. /**
  2068. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2069. * @param otherVector the vector to compare against
  2070. * @returns true if they are equal
  2071. */
  2072. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2073. /**
  2074. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2075. * @param otherVector vector to compare against
  2076. * @param epsilon (Default: very small number)
  2077. * @returns true if they are equal
  2078. */
  2079. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2080. /**
  2081. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2082. * @param x x value to compare against
  2083. * @param y y value to compare against
  2084. * @param z z value to compare against
  2085. * @param w w value to compare against
  2086. * @returns true if equal
  2087. */
  2088. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2089. /**
  2090. * Multiplies in place the current Vector4 by the given one.
  2091. * @param otherVector vector to multiple with
  2092. * @returns the updated Vector4.
  2093. */
  2094. multiplyInPlace(otherVector: Vector4): Vector4;
  2095. /**
  2096. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2097. * @param otherVector vector to multiple with
  2098. * @returns resulting new vector
  2099. */
  2100. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2101. /**
  2102. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2103. * @param otherVector vector to multiple with
  2104. * @param result vector to store the result
  2105. * @returns the current Vector4.
  2106. */
  2107. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2108. /**
  2109. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2110. * @param x x value multiply with
  2111. * @param y y value multiply with
  2112. * @param z z value multiply with
  2113. * @param w w value multiply with
  2114. * @returns resulting new vector
  2115. */
  2116. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2117. /**
  2118. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2119. * @param otherVector vector to devide with
  2120. * @returns resulting new vector
  2121. */
  2122. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2123. /**
  2124. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2125. * @param otherVector vector to devide with
  2126. * @param result vector to store the result
  2127. * @returns the current Vector4.
  2128. */
  2129. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2130. /**
  2131. * Divides the current Vector3 coordinates by the given ones.
  2132. * @param otherVector vector to devide with
  2133. * @returns the updated Vector3.
  2134. */
  2135. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2136. /**
  2137. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2138. * @param other defines the second operand
  2139. * @returns the current updated Vector4
  2140. */
  2141. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2142. /**
  2143. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2144. * @param other defines the second operand
  2145. * @returns the current updated Vector4
  2146. */
  2147. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2148. /**
  2149. * Gets a new Vector4 from current Vector4 floored values
  2150. * @returns a new Vector4
  2151. */
  2152. floor(): Vector4;
  2153. /**
  2154. * Gets a new Vector4 from current Vector3 floored values
  2155. * @returns a new Vector4
  2156. */
  2157. fract(): Vector4;
  2158. /**
  2159. * Returns the Vector4 length (float).
  2160. * @returns the length
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Returns the Vector4 squared length (float).
  2165. * @returns the length squared
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalizes in place the Vector4.
  2170. * @returns the updated Vector4.
  2171. */
  2172. normalize(): Vector4;
  2173. /**
  2174. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2175. * @returns this converted to a new vector3
  2176. */
  2177. toVector3(): Vector3;
  2178. /**
  2179. * Returns a new Vector4 copied from the current one.
  2180. * @returns the new cloned vector
  2181. */
  2182. clone(): Vector4;
  2183. /**
  2184. * Updates the current Vector4 with the given one coordinates.
  2185. * @param source the source vector to copy from
  2186. * @returns the updated Vector4.
  2187. */
  2188. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2189. /**
  2190. * Updates the current Vector4 coordinates with the given floats.
  2191. * @param x float to copy from
  2192. * @param y float to copy from
  2193. * @param z float to copy from
  2194. * @param w float to copy from
  2195. * @returns the updated Vector4.
  2196. */
  2197. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2198. /**
  2199. * Updates the current Vector4 coordinates with the given floats.
  2200. * @param x float to set from
  2201. * @param y float to set from
  2202. * @param z float to set from
  2203. * @param w float to set from
  2204. * @returns the updated Vector4.
  2205. */
  2206. set(x: number, y: number, z: number, w: number): Vector4;
  2207. /**
  2208. * Copies the given float to the current Vector3 coordinates
  2209. * @param v defines the x, y, z and w coordinates of the operand
  2210. * @returns the current updated Vector3
  2211. */
  2212. setAll(v: number): Vector4;
  2213. /**
  2214. * Returns a new Vector4 set from the starting index of the given array.
  2215. * @param array the array to pull values from
  2216. * @param offset the offset into the array to start at
  2217. * @returns the new vector
  2218. */
  2219. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2220. /**
  2221. * Updates the given vector "result" from the starting index of the given array.
  2222. * @param array the array to pull values from
  2223. * @param offset the offset into the array to start at
  2224. * @param result the vector to store the result in
  2225. */
  2226. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2227. /**
  2228. * Updates the given vector "result" from the starting index of the given Float32Array.
  2229. * @param array the array to pull values from
  2230. * @param offset the offset into the array to start at
  2231. * @param result the vector to store the result in
  2232. */
  2233. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2234. /**
  2235. * Updates the given vector "result" coordinates from the given floats.
  2236. * @param x float to set from
  2237. * @param y float to set from
  2238. * @param z float to set from
  2239. * @param w float to set from
  2240. * @param result the vector to the floats in
  2241. */
  2242. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2243. /**
  2244. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2245. * @returns the new vector
  2246. */
  2247. static Zero(): Vector4;
  2248. /**
  2249. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2250. * @returns the new vector
  2251. */
  2252. static One(): Vector4;
  2253. /**
  2254. * Returns a new normalized Vector4 from the given one.
  2255. * @param vector the vector to normalize
  2256. * @returns the vector
  2257. */
  2258. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2259. /**
  2260. * Updates the given vector "result" from the normalization of the given one.
  2261. * @param vector the vector to normalize
  2262. * @param result the vector to store the result in
  2263. */
  2264. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2265. /**
  2266. * Returns a vector with the minimum values from the left and right vectors
  2267. * @param left left vector to minimize
  2268. * @param right right vector to minimize
  2269. * @returns a new vector with the minimum of the left and right vector values
  2270. */
  2271. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2272. /**
  2273. * Returns a vector with the maximum values from the left and right vectors
  2274. * @param left left vector to maximize
  2275. * @param right right vector to maximize
  2276. * @returns a new vector with the maximum of the left and right vector values
  2277. */
  2278. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2279. /**
  2280. * Returns the distance (float) between the vectors "value1" and "value2".
  2281. * @param value1 value to calulate the distance between
  2282. * @param value2 value to calulate the distance between
  2283. * @return the distance between the two vectors
  2284. */
  2285. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2286. /**
  2287. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2288. * @param value1 value to calulate the distance between
  2289. * @param value2 value to calulate the distance between
  2290. * @return the distance between the two vectors squared
  2291. */
  2292. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2293. /**
  2294. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2295. * @param value1 value to calulate the center between
  2296. * @param value2 value to calulate the center between
  2297. * @return the center between the two vectors
  2298. */
  2299. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2300. /**
  2301. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2302. * This methods computes transformed normalized direction vectors only.
  2303. * @param vector the vector to transform
  2304. * @param transformation the transformation matrix to apply
  2305. * @returns the new vector
  2306. */
  2307. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2308. /**
  2309. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2310. * This methods computes transformed normalized direction vectors only.
  2311. * @param vector the vector to transform
  2312. * @param transformation the transformation matrix to apply
  2313. * @param result the vector to store the result in
  2314. */
  2315. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2316. /**
  2317. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2318. * This methods computes transformed normalized direction vectors only.
  2319. * @param x value to transform
  2320. * @param y value to transform
  2321. * @param z value to transform
  2322. * @param w value to transform
  2323. * @param transformation the transformation matrix to apply
  2324. * @param result the vector to store the results in
  2325. */
  2326. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2327. /**
  2328. * Creates a new Vector4 from a Vector3
  2329. * @param source defines the source data
  2330. * @param w defines the 4th component (default is 0)
  2331. * @returns a new Vector4
  2332. */
  2333. static FromVector3(source: Vector3, w?: number): Vector4;
  2334. }
  2335. /**
  2336. * Interface for the size containing width and height
  2337. */
  2338. export interface ISize {
  2339. /**
  2340. * Width
  2341. */
  2342. width: number;
  2343. /**
  2344. * Heighht
  2345. */
  2346. height: number;
  2347. }
  2348. /**
  2349. * Size containing widht and height
  2350. */
  2351. export class Size implements ISize {
  2352. /**
  2353. * Width
  2354. */
  2355. width: number;
  2356. /**
  2357. * Height
  2358. */
  2359. height: number;
  2360. /**
  2361. * Creates a Size object from the given width and height (floats).
  2362. * @param width width of the new size
  2363. * @param height height of the new size
  2364. */
  2365. constructor(width: number, height: number);
  2366. /**
  2367. * Returns a string with the Size width and height
  2368. * @returns a string with the Size width and height
  2369. */
  2370. toString(): string;
  2371. /**
  2372. * "Size"
  2373. * @returns the string "Size"
  2374. */
  2375. getClassName(): string;
  2376. /**
  2377. * Returns the Size hash code.
  2378. * @returns a hash code for a unique width and height
  2379. */
  2380. getHashCode(): number;
  2381. /**
  2382. * Updates the current size from the given one.
  2383. * @param src the given size
  2384. */
  2385. copyFrom(src: Size): void;
  2386. /**
  2387. * Updates in place the current Size from the given floats.
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. * @returns the updated Size.
  2391. */
  2392. copyFromFloats(width: number, height: number): Size;
  2393. /**
  2394. * Updates in place the current Size from the given floats.
  2395. * @param width width to set
  2396. * @param height height to set
  2397. * @returns the updated Size.
  2398. */
  2399. set(width: number, height: number): Size;
  2400. /**
  2401. * Multiplies the width and height by numbers
  2402. * @param w factor to multiple the width by
  2403. * @param h factor to multiple the height by
  2404. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2405. */
  2406. multiplyByFloats(w: number, h: number): Size;
  2407. /**
  2408. * Clones the size
  2409. * @returns a new Size copied from the given one.
  2410. */
  2411. clone(): Size;
  2412. /**
  2413. * True if the current Size and the given one width and height are strictly equal.
  2414. * @param other the other size to compare against
  2415. * @returns True if the current Size and the given one width and height are strictly equal.
  2416. */
  2417. equals(other: Size): boolean;
  2418. /**
  2419. * The surface of the Size : width * height (float).
  2420. */
  2421. readonly surface: number;
  2422. /**
  2423. * Create a new size of zero
  2424. * @returns a new Size set to (0.0, 0.0)
  2425. */
  2426. static Zero(): Size;
  2427. /**
  2428. * Sums the width and height of two sizes
  2429. * @param otherSize size to add to this size
  2430. * @returns a new Size set as the addition result of the current Size and the given one.
  2431. */
  2432. add(otherSize: Size): Size;
  2433. /**
  2434. * Subtracts the width and height of two
  2435. * @param otherSize size to subtract to this size
  2436. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2437. */
  2438. subtract(otherSize: Size): Size;
  2439. /**
  2440. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2441. * @param start starting size to lerp between
  2442. * @param end end size to lerp between
  2443. * @param amount amount to lerp between the start and end values
  2444. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2445. */
  2446. static Lerp(start: Size, end: Size, amount: number): Size;
  2447. }
  2448. /**
  2449. * Class used to store quaternion data
  2450. * @see https://en.wikipedia.org/wiki/Quaternion
  2451. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2452. */
  2453. export class Quaternion {
  2454. /** defines the first component (0 by default) */
  2455. x: number;
  2456. /** defines the second component (0 by default) */
  2457. y: number;
  2458. /** defines the third component (0 by default) */
  2459. z: number;
  2460. /** defines the fourth component (1.0 by default) */
  2461. w: number;
  2462. /**
  2463. * Creates a new Quaternion from the given floats
  2464. * @param x defines the first component (0 by default)
  2465. * @param y defines the second component (0 by default)
  2466. * @param z defines the third component (0 by default)
  2467. * @param w defines the fourth component (1.0 by default)
  2468. */
  2469. constructor(
  2470. /** defines the first component (0 by default) */
  2471. x?: number,
  2472. /** defines the second component (0 by default) */
  2473. y?: number,
  2474. /** defines the third component (0 by default) */
  2475. z?: number,
  2476. /** defines the fourth component (1.0 by default) */
  2477. w?: number);
  2478. /**
  2479. * Gets a string representation for the current quaternion
  2480. * @returns a string with the Quaternion coordinates
  2481. */
  2482. toString(): string;
  2483. /**
  2484. * Gets the class name of the quaternion
  2485. * @returns the string "Quaternion"
  2486. */
  2487. getClassName(): string;
  2488. /**
  2489. * Gets a hash code for this quaternion
  2490. * @returns the quaternion hash code
  2491. */
  2492. getHashCode(): number;
  2493. /**
  2494. * Copy the quaternion to an array
  2495. * @returns a new array populated with 4 elements from the quaternion coordinates
  2496. */
  2497. asArray(): number[];
  2498. /**
  2499. * Check if two quaternions are equals
  2500. * @param otherQuaternion defines the second operand
  2501. * @return true if the current quaternion and the given one coordinates are strictly equals
  2502. */
  2503. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2504. /**
  2505. * Clone the current quaternion
  2506. * @returns a new quaternion copied from the current one
  2507. */
  2508. clone(): Quaternion;
  2509. /**
  2510. * Copy a quaternion to the current one
  2511. * @param other defines the other quaternion
  2512. * @returns the updated current quaternion
  2513. */
  2514. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2515. /**
  2516. * Updates the current quaternion with the given float coordinates
  2517. * @param x defines the x coordinate
  2518. * @param y defines the y coordinate
  2519. * @param z defines the z coordinate
  2520. * @param w defines the w coordinate
  2521. * @returns the updated current quaternion
  2522. */
  2523. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2524. /**
  2525. * Updates the current quaternion from the given float coordinates
  2526. * @param x defines the x coordinate
  2527. * @param y defines the y coordinate
  2528. * @param z defines the z coordinate
  2529. * @param w defines the w coordinate
  2530. * @returns the updated current quaternion
  2531. */
  2532. set(x: number, y: number, z: number, w: number): Quaternion;
  2533. /**
  2534. * Adds two quaternions
  2535. * @param other defines the second operand
  2536. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2537. */
  2538. add(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Add a quaternion to the current one
  2541. * @param other defines the quaternion to add
  2542. * @returns the current quaternion
  2543. */
  2544. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2545. /**
  2546. * Subtract two quaternions
  2547. * @param other defines the second operand
  2548. * @returns a new quaternion as the subtraction result of the given one from the current one
  2549. */
  2550. subtract(other: Quaternion): Quaternion;
  2551. /**
  2552. * Multiplies the current quaternion by a scale factor
  2553. * @param value defines the scale factor
  2554. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2555. */
  2556. scale(value: number): Quaternion;
  2557. /**
  2558. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2559. * @param scale defines the scale factor
  2560. * @param result defines the Quaternion object where to store the result
  2561. * @returns the unmodified current quaternion
  2562. */
  2563. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2564. /**
  2565. * Multiplies in place the current quaternion by a scale factor
  2566. * @param value defines the scale factor
  2567. * @returns the current modified quaternion
  2568. */
  2569. scaleInPlace(value: number): Quaternion;
  2570. /**
  2571. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2572. * @param scale defines the scale factor
  2573. * @param result defines the Quaternion object where to store the result
  2574. * @returns the unmodified current quaternion
  2575. */
  2576. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies two quaternions
  2579. * @param q1 defines the second operand
  2580. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2581. */
  2582. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2583. /**
  2584. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2585. * @param q1 defines the second operand
  2586. * @param result defines the target quaternion
  2587. * @returns the current quaternion
  2588. */
  2589. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2590. /**
  2591. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2592. * @param q1 defines the second operand
  2593. * @returns the currentupdated quaternion
  2594. */
  2595. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2596. /**
  2597. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2598. * @param ref defines the target quaternion
  2599. * @returns the current quaternion
  2600. */
  2601. conjugateToRef(ref: Quaternion): Quaternion;
  2602. /**
  2603. * Conjugates in place (1-q) the current quaternion
  2604. * @returns the current updated quaternion
  2605. */
  2606. conjugateInPlace(): Quaternion;
  2607. /**
  2608. * Conjugates in place (1-q) the current quaternion
  2609. * @returns a new quaternion
  2610. */
  2611. conjugate(): Quaternion;
  2612. /**
  2613. * Gets length of current quaternion
  2614. * @returns the quaternion length (float)
  2615. */
  2616. length(): number;
  2617. /**
  2618. * Normalize in place the current quaternion
  2619. * @returns the current updated quaternion
  2620. */
  2621. normalize(): Quaternion;
  2622. /**
  2623. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2624. * @param order is a reserved parameter and is ignore for now
  2625. * @returns a new Vector3 containing the Euler angles
  2626. */
  2627. toEulerAngles(order?: string): Vector3;
  2628. /**
  2629. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2630. * @param result defines the vector which will be filled with the Euler angles
  2631. * @param order is a reserved parameter and is ignore for now
  2632. * @returns the current unchanged quaternion
  2633. */
  2634. toEulerAnglesToRef(result: Vector3): Quaternion;
  2635. /**
  2636. * Updates the given rotation matrix with the current quaternion values
  2637. * @param result defines the target matrix
  2638. * @returns the current unchanged quaternion
  2639. */
  2640. toRotationMatrix(result: Matrix): Quaternion;
  2641. /**
  2642. * Updates the current quaternion from the given rotation matrix values
  2643. * @param matrix defines the source matrix
  2644. * @returns the current updated quaternion
  2645. */
  2646. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2647. /**
  2648. * Creates a new quaternion from a rotation matrix
  2649. * @param matrix defines the source matrix
  2650. * @returns a new quaternion created from the given rotation matrix values
  2651. */
  2652. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2653. /**
  2654. * Updates the given quaternion with the given rotation matrix values
  2655. * @param matrix defines the source matrix
  2656. * @param result defines the target quaternion
  2657. */
  2658. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2659. /**
  2660. * Returns the dot product (float) between the quaternions "left" and "right"
  2661. * @param left defines the left operand
  2662. * @param right defines the right operand
  2663. * @returns the dot product
  2664. */
  2665. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2666. /**
  2667. * Checks if the two quaternions are close to each other
  2668. * @param quat0 defines the first quaternion to check
  2669. * @param quat1 defines the second quaternion to check
  2670. * @returns true if the two quaternions are close to each other
  2671. */
  2672. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2673. /**
  2674. * Creates an empty quaternion
  2675. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2676. */
  2677. static Zero(): Quaternion;
  2678. /**
  2679. * Inverse a given quaternion
  2680. * @param q defines the source quaternion
  2681. * @returns a new quaternion as the inverted current quaternion
  2682. */
  2683. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2684. /**
  2685. * Inverse a given quaternion
  2686. * @param q defines the source quaternion
  2687. * @param result the quaternion the result will be stored in
  2688. * @returns the result quaternion
  2689. */
  2690. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2691. /**
  2692. * Creates an identity quaternion
  2693. * @returns the identity quaternion
  2694. */
  2695. static Identity(): Quaternion;
  2696. /**
  2697. * Gets a boolean indicating if the given quaternion is identity
  2698. * @param quaternion defines the quaternion to check
  2699. * @returns true if the quaternion is identity
  2700. */
  2701. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2702. /**
  2703. * Creates a quaternion from a rotation around an axis
  2704. * @param axis defines the axis to use
  2705. * @param angle defines the angle to use
  2706. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2707. */
  2708. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2709. /**
  2710. * Creates a rotation around an axis and stores it into the given quaternion
  2711. * @param axis defines the axis to use
  2712. * @param angle defines the angle to use
  2713. * @param result defines the target quaternion
  2714. * @returns the target quaternion
  2715. */
  2716. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates a new quaternion from data stored into an array
  2719. * @param array defines the data source
  2720. * @param offset defines the offset in the source array where the data starts
  2721. * @returns a new quaternion
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2724. /**
  2725. * Create a quaternion from Euler rotation angles
  2726. * @param x Pitch
  2727. * @param y Yaw
  2728. * @param z Roll
  2729. * @returns the new Quaternion
  2730. */
  2731. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2732. /**
  2733. * Updates a quaternion from Euler rotation angles
  2734. * @param x Pitch
  2735. * @param y Yaw
  2736. * @param z Roll
  2737. * @param result the quaternion to store the result
  2738. * @returns the updated quaternion
  2739. */
  2740. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Create a quaternion from Euler rotation vector
  2743. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2744. * @returns the new Quaternion
  2745. */
  2746. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2747. /**
  2748. * Updates a quaternion from Euler rotation vector
  2749. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2750. * @param result the quaternion to store the result
  2751. * @returns the updated quaternion
  2752. */
  2753. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2754. /**
  2755. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2756. * @param yaw defines the rotation around Y axis
  2757. * @param pitch defines the rotation around X axis
  2758. * @param roll defines the rotation around Z axis
  2759. * @returns the new quaternion
  2760. */
  2761. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2762. /**
  2763. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2764. * @param yaw defines the rotation around Y axis
  2765. * @param pitch defines the rotation around X axis
  2766. * @param roll defines the rotation around Z axis
  2767. * @param result defines the target quaternion
  2768. */
  2769. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2770. /**
  2771. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2772. * @param alpha defines the rotation around first axis
  2773. * @param beta defines the rotation around second axis
  2774. * @param gamma defines the rotation around third axis
  2775. * @returns the new quaternion
  2776. */
  2777. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2780. * @param alpha defines the rotation around first axis
  2781. * @param beta defines the rotation around second axis
  2782. * @param gamma defines the rotation around third axis
  2783. * @param result defines the target quaternion
  2784. */
  2785. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2786. /**
  2787. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2788. * @param axis1 defines the first axis
  2789. * @param axis2 defines the second axis
  2790. * @param axis3 defines the third axis
  2791. * @returns the new quaternion
  2792. */
  2793. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2794. /**
  2795. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2796. * @param axis1 defines the first axis
  2797. * @param axis2 defines the second axis
  2798. * @param axis3 defines the third axis
  2799. * @param ref defines the target quaternion
  2800. */
  2801. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2802. /**
  2803. * Interpolates between two quaternions
  2804. * @param left defines first quaternion
  2805. * @param right defines second quaternion
  2806. * @param amount defines the gradient to use
  2807. * @returns the new interpolated quaternion
  2808. */
  2809. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2810. /**
  2811. * Interpolates between two quaternions and stores it into a target quaternion
  2812. * @param left defines first quaternion
  2813. * @param right defines second quaternion
  2814. * @param amount defines the gradient to use
  2815. * @param result defines the target quaternion
  2816. */
  2817. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2818. /**
  2819. * Interpolate between two quaternions using Hermite interpolation
  2820. * @param value1 defines first quaternion
  2821. * @param tangent1 defines the incoming tangent
  2822. * @param value2 defines second quaternion
  2823. * @param tangent2 defines the outgoing tangent
  2824. * @param amount defines the target quaternion
  2825. * @returns the new interpolated quaternion
  2826. */
  2827. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2828. }
  2829. /**
  2830. * Class used to store matrix data (4x4)
  2831. */
  2832. export class Matrix {
  2833. private static _updateFlagSeed;
  2834. private static _identityReadOnly;
  2835. private _isIdentity;
  2836. private _isIdentityDirty;
  2837. private _isIdentity3x2;
  2838. private _isIdentity3x2Dirty;
  2839. /**
  2840. * Gets the update flag of the matrix which is an unique number for the matrix.
  2841. * It will be incremented every time the matrix data change.
  2842. * You can use it to speed the comparison between two versions of the same matrix.
  2843. */
  2844. updateFlag: number;
  2845. private readonly _m;
  2846. /**
  2847. * Gets the internal data of the matrix
  2848. */
  2849. readonly m: DeepImmutable<Float32Array>;
  2850. /** @hidden */ markAsUpdated(): void;
  2851. /** @hidden */
  2852. private _updateIdentityStatus;
  2853. /**
  2854. * Creates an empty matrix (filled with zeros)
  2855. */
  2856. constructor();
  2857. /**
  2858. * Check if the current matrix is identity
  2859. * @returns true is the matrix is the identity matrix
  2860. */
  2861. isIdentity(): boolean;
  2862. /**
  2863. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2864. * @returns true is the matrix is the identity matrix
  2865. */
  2866. isIdentityAs3x2(): boolean;
  2867. /**
  2868. * Gets the determinant of the matrix
  2869. * @returns the matrix determinant
  2870. */
  2871. determinant(): number;
  2872. /**
  2873. * Returns the matrix as a Float32Array
  2874. * @returns the matrix underlying array
  2875. */
  2876. toArray(): DeepImmutable<Float32Array>;
  2877. /**
  2878. * Returns the matrix as a Float32Array
  2879. * @returns the matrix underlying array.
  2880. */
  2881. asArray(): DeepImmutable<Float32Array>;
  2882. /**
  2883. * Inverts the current matrix in place
  2884. * @returns the current inverted matrix
  2885. */
  2886. invert(): Matrix;
  2887. /**
  2888. * Sets all the matrix elements to zero
  2889. * @returns the current matrix
  2890. */
  2891. reset(): Matrix;
  2892. /**
  2893. * Adds the current matrix with a second one
  2894. * @param other defines the matrix to add
  2895. * @returns a new matrix as the addition of the current matrix and the given one
  2896. */
  2897. add(other: DeepImmutable<Matrix>): Matrix;
  2898. /**
  2899. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2900. * @param other defines the matrix to add
  2901. * @param result defines the target matrix
  2902. * @returns the current matrix
  2903. */
  2904. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2905. /**
  2906. * Adds in place the given matrix to the current matrix
  2907. * @param other defines the second operand
  2908. * @returns the current updated matrix
  2909. */
  2910. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2911. /**
  2912. * Sets the given matrix to the current inverted Matrix
  2913. * @param other defines the target matrix
  2914. * @returns the unmodified current matrix
  2915. */
  2916. invertToRef(other: Matrix): Matrix;
  2917. /**
  2918. * add a value at the specified position in the current Matrix
  2919. * @param index the index of the value within the matrix. between 0 and 15.
  2920. * @param value the value to be added
  2921. * @returns the current updated matrix
  2922. */
  2923. addAtIndex(index: number, value: number): Matrix;
  2924. /**
  2925. * mutiply the specified position in the current Matrix by a value
  2926. * @param index the index of the value within the matrix. between 0 and 15.
  2927. * @param value the value to be added
  2928. * @returns the current updated matrix
  2929. */
  2930. multiplyAtIndex(index: number, value: number): Matrix;
  2931. /**
  2932. * Inserts the translation vector (using 3 floats) in the current matrix
  2933. * @param x defines the 1st component of the translation
  2934. * @param y defines the 2nd component of the translation
  2935. * @param z defines the 3rd component of the translation
  2936. * @returns the current updated matrix
  2937. */
  2938. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2939. /**
  2940. * Adds the translation vector (using 3 floats) in the current matrix
  2941. * @param x defines the 1st component of the translation
  2942. * @param y defines the 2nd component of the translation
  2943. * @param z defines the 3rd component of the translation
  2944. * @returns the current updated matrix
  2945. */
  2946. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2947. /**
  2948. * Inserts the translation vector in the current matrix
  2949. * @param vector3 defines the translation to insert
  2950. * @returns the current updated matrix
  2951. */
  2952. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2953. /**
  2954. * Gets the translation value of the current matrix
  2955. * @returns a new Vector3 as the extracted translation from the matrix
  2956. */
  2957. getTranslation(): Vector3;
  2958. /**
  2959. * Fill a Vector3 with the extracted translation from the matrix
  2960. * @param result defines the Vector3 where to store the translation
  2961. * @returns the current matrix
  2962. */
  2963. getTranslationToRef(result: Vector3): Matrix;
  2964. /**
  2965. * Remove rotation and scaling part from the matrix
  2966. * @returns the updated matrix
  2967. */
  2968. removeRotationAndScaling(): Matrix;
  2969. /**
  2970. * Multiply two matrices
  2971. * @param other defines the second operand
  2972. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2973. */
  2974. multiply(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Copy the current matrix from the given one
  2977. * @param other defines the source matrix
  2978. * @returns the current updated matrix
  2979. */
  2980. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2981. /**
  2982. * Populates the given array from the starting index with the current matrix values
  2983. * @param array defines the target array
  2984. * @param offset defines the offset in the target array where to start storing values
  2985. * @returns the current matrix
  2986. */
  2987. copyToArray(array: Float32Array, offset?: number): Matrix;
  2988. /**
  2989. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2990. * @param other defines the second operand
  2991. * @param result defines the matrix where to store the multiplication
  2992. * @returns the current matrix
  2993. */
  2994. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2995. /**
  2996. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2997. * @param other defines the second operand
  2998. * @param result defines the array where to store the multiplication
  2999. * @param offset defines the offset in the target array where to start storing values
  3000. * @returns the current matrix
  3001. */
  3002. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3003. /**
  3004. * Check equality between this matrix and a second one
  3005. * @param value defines the second matrix to compare
  3006. * @returns true is the current matrix and the given one values are strictly equal
  3007. */
  3008. equals(value: DeepImmutable<Matrix>): boolean;
  3009. /**
  3010. * Clone the current matrix
  3011. * @returns a new matrix from the current matrix
  3012. */
  3013. clone(): Matrix;
  3014. /**
  3015. * Returns the name of the current matrix class
  3016. * @returns the string "Matrix"
  3017. */
  3018. getClassName(): string;
  3019. /**
  3020. * Gets the hash code of the current matrix
  3021. * @returns the hash code
  3022. */
  3023. getHashCode(): number;
  3024. /**
  3025. * Decomposes the current Matrix into a translation, rotation and scaling components
  3026. * @param scale defines the scale vector3 given as a reference to update
  3027. * @param rotation defines the rotation quaternion given as a reference to update
  3028. * @param translation defines the translation vector3 given as a reference to update
  3029. * @returns true if operation was successful
  3030. */
  3031. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3032. /**
  3033. * Gets specific row of the matrix
  3034. * @param index defines the number of the row to get
  3035. * @returns the index-th row of the current matrix as a new Vector4
  3036. */
  3037. getRow(index: number): Nullable<Vector4>;
  3038. /**
  3039. * Sets the index-th row of the current matrix to the vector4 values
  3040. * @param index defines the number of the row to set
  3041. * @param row defines the target vector4
  3042. * @returns the updated current matrix
  3043. */
  3044. setRow(index: number, row: Vector4): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix
  3047. * @returns the new transposed matrix
  3048. */
  3049. transpose(): Matrix;
  3050. /**
  3051. * Compute the transpose of the matrix and store it in a given matrix
  3052. * @param result defines the target matrix
  3053. * @returns the current matrix
  3054. */
  3055. transposeToRef(result: Matrix): Matrix;
  3056. /**
  3057. * Sets the index-th row of the current matrix with the given 4 x float values
  3058. * @param index defines the row index
  3059. * @param x defines the x component to set
  3060. * @param y defines the y component to set
  3061. * @param z defines the z component to set
  3062. * @param w defines the w component to set
  3063. * @returns the updated current matrix
  3064. */
  3065. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3066. /**
  3067. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3068. * @param scale defines the scale factor
  3069. * @returns a new matrix
  3070. */
  3071. scale(scale: number): Matrix;
  3072. /**
  3073. * Scale the current matrix values by a factor to a given result matrix
  3074. * @param scale defines the scale factor
  3075. * @param result defines the matrix to store the result
  3076. * @returns the current matrix
  3077. */
  3078. scaleToRef(scale: number, result: Matrix): Matrix;
  3079. /**
  3080. * Scale the current matrix values by a factor and add the result to a given matrix
  3081. * @param scale defines the scale factor
  3082. * @param result defines the Matrix to store the result
  3083. * @returns the current matrix
  3084. */
  3085. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3086. /**
  3087. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3088. * @param ref matrix to store the result
  3089. */
  3090. toNormalMatrix(ref: Matrix): void;
  3091. /**
  3092. * Gets only rotation part of the current matrix
  3093. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3094. */
  3095. getRotationMatrix(): Matrix;
  3096. /**
  3097. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3098. * @param result defines the target matrix to store data to
  3099. * @returns the current matrix
  3100. */
  3101. getRotationMatrixToRef(result: Matrix): Matrix;
  3102. /**
  3103. * Toggles model matrix from being right handed to left handed in place and vice versa
  3104. */
  3105. toggleModelMatrixHandInPlace(): void;
  3106. /**
  3107. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleProjectionMatrixHandInPlace(): void;
  3110. /**
  3111. * Creates a matrix from an array
  3112. * @param array defines the source array
  3113. * @param offset defines an offset in the source array
  3114. * @returns a new Matrix set from the starting index of the given array
  3115. */
  3116. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3117. /**
  3118. * Copy the content of an array into a given matrix
  3119. * @param array defines the source array
  3120. * @param offset defines an offset in the source array
  3121. * @param result defines the target matrix
  3122. */
  3123. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3124. /**
  3125. * Stores an array into a matrix after having multiplied each component by a given factor
  3126. * @param array defines the source array
  3127. * @param offset defines the offset in the source array
  3128. * @param scale defines the scaling factor
  3129. * @param result defines the target matrix
  3130. */
  3131. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3132. /**
  3133. * Gets an identity matrix that must not be updated
  3134. */
  3135. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3136. /**
  3137. * Stores a list of values (16) inside a given matrix
  3138. * @param initialM11 defines 1st value of 1st row
  3139. * @param initialM12 defines 2nd value of 1st row
  3140. * @param initialM13 defines 3rd value of 1st row
  3141. * @param initialM14 defines 4th value of 1st row
  3142. * @param initialM21 defines 1st value of 2nd row
  3143. * @param initialM22 defines 2nd value of 2nd row
  3144. * @param initialM23 defines 3rd value of 2nd row
  3145. * @param initialM24 defines 4th value of 2nd row
  3146. * @param initialM31 defines 1st value of 3rd row
  3147. * @param initialM32 defines 2nd value of 3rd row
  3148. * @param initialM33 defines 3rd value of 3rd row
  3149. * @param initialM34 defines 4th value of 3rd row
  3150. * @param initialM41 defines 1st value of 4th row
  3151. * @param initialM42 defines 2nd value of 4th row
  3152. * @param initialM43 defines 3rd value of 4th row
  3153. * @param initialM44 defines 4th value of 4th row
  3154. * @param result defines the target matrix
  3155. */
  3156. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3157. /**
  3158. * Creates new matrix from a list of values (16)
  3159. * @param initialM11 defines 1st value of 1st row
  3160. * @param initialM12 defines 2nd value of 1st row
  3161. * @param initialM13 defines 3rd value of 1st row
  3162. * @param initialM14 defines 4th value of 1st row
  3163. * @param initialM21 defines 1st value of 2nd row
  3164. * @param initialM22 defines 2nd value of 2nd row
  3165. * @param initialM23 defines 3rd value of 2nd row
  3166. * @param initialM24 defines 4th value of 2nd row
  3167. * @param initialM31 defines 1st value of 3rd row
  3168. * @param initialM32 defines 2nd value of 3rd row
  3169. * @param initialM33 defines 3rd value of 3rd row
  3170. * @param initialM34 defines 4th value of 3rd row
  3171. * @param initialM41 defines 1st value of 4th row
  3172. * @param initialM42 defines 2nd value of 4th row
  3173. * @param initialM43 defines 3rd value of 4th row
  3174. * @param initialM44 defines 4th value of 4th row
  3175. * @returns the new matrix
  3176. */
  3177. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3178. /**
  3179. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3180. * @param scale defines the scale vector3
  3181. * @param rotation defines the rotation quaternion
  3182. * @param translation defines the translation vector3
  3183. * @returns a new matrix
  3184. */
  3185. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3186. /**
  3187. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3188. * @param scale defines the scale vector3
  3189. * @param rotation defines the rotation quaternion
  3190. * @param translation defines the translation vector3
  3191. * @param result defines the target matrix
  3192. */
  3193. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3194. /**
  3195. * Creates a new identity matrix
  3196. * @returns a new identity matrix
  3197. */
  3198. static Identity(): Matrix;
  3199. /**
  3200. * Creates a new identity matrix and stores the result in a given matrix
  3201. * @param result defines the target matrix
  3202. */
  3203. static IdentityToRef(result: Matrix): void;
  3204. /**
  3205. * Creates a new zero matrix
  3206. * @returns a new zero matrix
  3207. */
  3208. static Zero(): Matrix;
  3209. /**
  3210. * Creates a new rotation matrix for "angle" radians around the X axis
  3211. * @param angle defines the angle (in radians) to use
  3212. * @return the new matrix
  3213. */
  3214. static RotationX(angle: number): Matrix;
  3215. /**
  3216. * Creates a new matrix as the invert of a given matrix
  3217. * @param source defines the source matrix
  3218. * @returns the new matrix
  3219. */
  3220. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3223. * @param angle defines the angle (in radians) to use
  3224. * @param result defines the target matrix
  3225. */
  3226. static RotationXToRef(angle: number, result: Matrix): void;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis
  3229. * @param angle defines the angle (in radians) to use
  3230. * @return the new matrix
  3231. */
  3232. static RotationY(angle: number): Matrix;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3235. * @param angle defines the angle (in radians) to use
  3236. * @param result defines the target matrix
  3237. */
  3238. static RotationYToRef(angle: number, result: Matrix): void;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis
  3241. * @param angle defines the angle (in radians) to use
  3242. * @return the new matrix
  3243. */
  3244. static RotationZ(angle: number): Matrix;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3247. * @param angle defines the angle (in radians) to use
  3248. * @param result defines the target matrix
  3249. */
  3250. static RotationZToRef(angle: number, result: Matrix): void;
  3251. /**
  3252. * Creates a new rotation matrix for "angle" radians around the given axis
  3253. * @param axis defines the axis to use
  3254. * @param angle defines the angle (in radians) to use
  3255. * @return the new matrix
  3256. */
  3257. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3258. /**
  3259. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3260. * @param axis defines the axis to use
  3261. * @param angle defines the angle (in radians) to use
  3262. * @param result defines the target matrix
  3263. */
  3264. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3265. /**
  3266. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3267. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3268. * @param from defines the vector to align
  3269. * @param to defines the vector to align to
  3270. * @param result defines the target matrix
  3271. */
  3272. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3273. /**
  3274. * Creates a rotation matrix
  3275. * @param yaw defines the yaw angle in radians (Y axis)
  3276. * @param pitch defines the pitch angle in radians (X axis)
  3277. * @param roll defines the roll angle in radians (X axis)
  3278. * @returns the new rotation matrix
  3279. */
  3280. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3281. /**
  3282. * Creates a rotation matrix and stores it in a given matrix
  3283. * @param yaw defines the yaw angle in radians (Y axis)
  3284. * @param pitch defines the pitch angle in radians (X axis)
  3285. * @param roll defines the roll angle in radians (X axis)
  3286. * @param result defines the target matrix
  3287. */
  3288. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3289. /**
  3290. * Creates a scaling matrix
  3291. * @param x defines the scale factor on X axis
  3292. * @param y defines the scale factor on Y axis
  3293. * @param z defines the scale factor on Z axis
  3294. * @returns the new matrix
  3295. */
  3296. static Scaling(x: number, y: number, z: number): Matrix;
  3297. /**
  3298. * Creates a scaling matrix and stores it in a given matrix
  3299. * @param x defines the scale factor on X axis
  3300. * @param y defines the scale factor on Y axis
  3301. * @param z defines the scale factor on Z axis
  3302. * @param result defines the target matrix
  3303. */
  3304. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3305. /**
  3306. * Creates a translation matrix
  3307. * @param x defines the translation on X axis
  3308. * @param y defines the translation on Y axis
  3309. * @param z defines the translationon Z axis
  3310. * @returns the new matrix
  3311. */
  3312. static Translation(x: number, y: number, z: number): Matrix;
  3313. /**
  3314. * Creates a translation matrix and stores it in a given matrix
  3315. * @param x defines the translation on X axis
  3316. * @param y defines the translation on Y axis
  3317. * @param z defines the translationon Z axis
  3318. * @param result defines the target matrix
  3319. */
  3320. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3321. /**
  3322. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3323. * @param startValue defines the start value
  3324. * @param endValue defines the end value
  3325. * @param gradient defines the gradient factor
  3326. * @returns the new matrix
  3327. */
  3328. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3329. /**
  3330. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3331. * @param startValue defines the start value
  3332. * @param endValue defines the end value
  3333. * @param gradient defines the gradient factor
  3334. * @param result defines the Matrix object where to store data
  3335. */
  3336. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3337. /**
  3338. * Builds a new matrix whose values are computed by:
  3339. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3340. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3341. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3342. * @param startValue defines the first matrix
  3343. * @param endValue defines the second matrix
  3344. * @param gradient defines the gradient between the two matrices
  3345. * @returns the new matrix
  3346. */
  3347. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3348. /**
  3349. * Update a matrix to values which are computed by:
  3350. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3351. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3352. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3353. * @param startValue defines the first matrix
  3354. * @param endValue defines the second matrix
  3355. * @param gradient defines the gradient between the two matrices
  3356. * @param result defines the target matrix
  3357. */
  3358. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3359. /**
  3360. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3361. * This function works in left handed mode
  3362. * @param eye defines the final position of the entity
  3363. * @param target defines where the entity should look at
  3364. * @param up defines the up vector for the entity
  3365. * @returns the new matrix
  3366. */
  3367. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3368. /**
  3369. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3370. * This function works in left handed mode
  3371. * @param eye defines the final position of the entity
  3372. * @param target defines where the entity should look at
  3373. * @param up defines the up vector for the entity
  3374. * @param result defines the target matrix
  3375. */
  3376. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3377. /**
  3378. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3379. * This function works in right handed mode
  3380. * @param eye defines the final position of the entity
  3381. * @param target defines where the entity should look at
  3382. * @param up defines the up vector for the entity
  3383. * @returns the new matrix
  3384. */
  3385. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3386. /**
  3387. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3388. * This function works in right handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @param result defines the target matrix
  3393. */
  3394. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3395. /**
  3396. * Create a left-handed orthographic projection matrix
  3397. * @param width defines the viewport width
  3398. * @param height defines the viewport height
  3399. * @param znear defines the near clip plane
  3400. * @param zfar defines the far clip plane
  3401. * @returns a new matrix as a left-handed orthographic projection matrix
  3402. */
  3403. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3404. /**
  3405. * Store a left-handed orthographic projection to a given matrix
  3406. * @param width defines the viewport width
  3407. * @param height defines the viewport height
  3408. * @param znear defines the near clip plane
  3409. * @param zfar defines the far clip plane
  3410. * @param result defines the target matrix
  3411. */
  3412. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3413. /**
  3414. * Create a left-handed orthographic projection matrix
  3415. * @param left defines the viewport left coordinate
  3416. * @param right defines the viewport right coordinate
  3417. * @param bottom defines the viewport bottom coordinate
  3418. * @param top defines the viewport top coordinate
  3419. * @param znear defines the near clip plane
  3420. * @param zfar defines the far clip plane
  3421. * @returns a new matrix as a left-handed orthographic projection matrix
  3422. */
  3423. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3424. /**
  3425. * Stores a left-handed orthographic projection into a given matrix
  3426. * @param left defines the viewport left coordinate
  3427. * @param right defines the viewport right coordinate
  3428. * @param bottom defines the viewport bottom coordinate
  3429. * @param top defines the viewport top coordinate
  3430. * @param znear defines the near clip plane
  3431. * @param zfar defines the far clip plane
  3432. * @param result defines the target matrix
  3433. */
  3434. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3435. /**
  3436. * Creates a right-handed orthographic projection matrix
  3437. * @param left defines the viewport left coordinate
  3438. * @param right defines the viewport right coordinate
  3439. * @param bottom defines the viewport bottom coordinate
  3440. * @param top defines the viewport top coordinate
  3441. * @param znear defines the near clip plane
  3442. * @param zfar defines the far clip plane
  3443. * @returns a new matrix as a right-handed orthographic projection matrix
  3444. */
  3445. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3446. /**
  3447. * Stores a right-handed orthographic projection into a given matrix
  3448. * @param left defines the viewport left coordinate
  3449. * @param right defines the viewport right coordinate
  3450. * @param bottom defines the viewport bottom coordinate
  3451. * @param top defines the viewport top coordinate
  3452. * @param znear defines the near clip plane
  3453. * @param zfar defines the far clip plane
  3454. * @param result defines the target matrix
  3455. */
  3456. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3457. /**
  3458. * Creates a left-handed perspective projection matrix
  3459. * @param width defines the viewport width
  3460. * @param height defines the viewport height
  3461. * @param znear defines the near clip plane
  3462. * @param zfar defines the far clip plane
  3463. * @returns a new matrix as a left-handed perspective projection matrix
  3464. */
  3465. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3466. /**
  3467. * Creates a left-handed perspective projection matrix
  3468. * @param fov defines the horizontal field of view
  3469. * @param aspect defines the aspect ratio
  3470. * @param znear defines the near clip plane
  3471. * @param zfar defines the far clip plane
  3472. * @returns a new matrix as a left-handed perspective projection matrix
  3473. */
  3474. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3475. /**
  3476. * Stores a left-handed perspective projection into a given matrix
  3477. * @param fov defines the horizontal field of view
  3478. * @param aspect defines the aspect ratio
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3483. */
  3484. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3485. /**
  3486. * Creates a right-handed perspective projection matrix
  3487. * @param fov defines the horizontal field of view
  3488. * @param aspect defines the aspect ratio
  3489. * @param znear defines the near clip plane
  3490. * @param zfar defines the far clip plane
  3491. * @returns a new matrix as a right-handed perspective projection matrix
  3492. */
  3493. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3494. /**
  3495. * Stores a right-handed perspective projection into a given matrix
  3496. * @param fov defines the horizontal field of view
  3497. * @param aspect defines the aspect ratio
  3498. * @param znear defines the near clip plane
  3499. * @param zfar defines the far clip plane
  3500. * @param result defines the target matrix
  3501. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3502. */
  3503. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3504. /**
  3505. * Stores a perspective projection for WebVR info a given matrix
  3506. * @param fov defines the field of view
  3507. * @param znear defines the near clip plane
  3508. * @param zfar defines the far clip plane
  3509. * @param result defines the target matrix
  3510. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3511. */
  3512. static PerspectiveFovWebVRToRef(fov: {
  3513. upDegrees: number;
  3514. downDegrees: number;
  3515. leftDegrees: number;
  3516. rightDegrees: number;
  3517. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3518. /**
  3519. * Computes a complete transformation matrix
  3520. * @param viewport defines the viewport to use
  3521. * @param world defines the world matrix
  3522. * @param view defines the view matrix
  3523. * @param projection defines the projection matrix
  3524. * @param zmin defines the near clip plane
  3525. * @param zmax defines the far clip plane
  3526. * @returns the transformation matrix
  3527. */
  3528. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3529. /**
  3530. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3531. * @param matrix defines the matrix to use
  3532. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3533. */
  3534. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3535. /**
  3536. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3537. * @param matrix defines the matrix to use
  3538. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3539. */
  3540. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3541. /**
  3542. * Compute the transpose of a given matrix
  3543. * @param matrix defines the matrix to transpose
  3544. * @returns the new matrix
  3545. */
  3546. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3547. /**
  3548. * Compute the transpose of a matrix and store it in a target matrix
  3549. * @param matrix defines the matrix to transpose
  3550. * @param result defines the target matrix
  3551. */
  3552. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3553. /**
  3554. * Computes a reflection matrix from a plane
  3555. * @param plane defines the reflection plane
  3556. * @returns a new matrix
  3557. */
  3558. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3559. /**
  3560. * Computes a reflection matrix from a plane
  3561. * @param plane defines the reflection plane
  3562. * @param result defines the target matrix
  3563. */
  3564. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3565. /**
  3566. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3567. * @param xaxis defines the value of the 1st axis
  3568. * @param yaxis defines the value of the 2nd axis
  3569. * @param zaxis defines the value of the 3rd axis
  3570. * @param result defines the target matrix
  3571. */
  3572. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3573. /**
  3574. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3575. * @param quat defines the quaternion to use
  3576. * @param result defines the target matrix
  3577. */
  3578. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3579. }
  3580. /**
  3581. * Represens a plane by the equation ax + by + cz + d = 0
  3582. */
  3583. export class Plane {
  3584. /**
  3585. * Normal of the plane (a,b,c)
  3586. */
  3587. normal: Vector3;
  3588. /**
  3589. * d component of the plane
  3590. */
  3591. d: number;
  3592. /**
  3593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3594. * @param a a component of the plane
  3595. * @param b b component of the plane
  3596. * @param c c component of the plane
  3597. * @param d d component of the plane
  3598. */
  3599. constructor(a: number, b: number, c: number, d: number);
  3600. /**
  3601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3602. */
  3603. asArray(): number[];
  3604. /**
  3605. * @returns a new plane copied from the current Plane.
  3606. */
  3607. clone(): Plane;
  3608. /**
  3609. * @returns the string "Plane".
  3610. */
  3611. getClassName(): string;
  3612. /**
  3613. * @returns the Plane hash code.
  3614. */
  3615. getHashCode(): number;
  3616. /**
  3617. * Normalize the current Plane in place.
  3618. * @returns the updated Plane.
  3619. */
  3620. normalize(): Plane;
  3621. /**
  3622. * Applies a transformation the plane and returns the result
  3623. * @param transformation the transformation matrix to be applied to the plane
  3624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3625. */
  3626. transform(transformation: DeepImmutable<Matrix>): Plane;
  3627. /**
  3628. * Calcualtte the dot product between the point and the plane normal
  3629. * @param point point to calculate the dot product with
  3630. * @returns the dot product (float) of the point coordinates and the plane normal.
  3631. */
  3632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3633. /**
  3634. * Updates the current Plane from the plane defined by the three given points.
  3635. * @param point1 one of the points used to contruct the plane
  3636. * @param point2 one of the points used to contruct the plane
  3637. * @param point3 one of the points used to contruct the plane
  3638. * @returns the updated Plane.
  3639. */
  3640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3641. /**
  3642. * Checks if the plane is facing a given direction
  3643. * @param direction the direction to check if the plane is facing
  3644. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3645. * @returns True is the vector "direction" is the same side than the plane normal.
  3646. */
  3647. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3648. /**
  3649. * Calculates the distance to a point
  3650. * @param point point to calculate distance to
  3651. * @returns the signed distance (float) from the given point to the Plane.
  3652. */
  3653. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3654. /**
  3655. * Creates a plane from an array
  3656. * @param array the array to create a plane from
  3657. * @returns a new Plane from the given array.
  3658. */
  3659. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3660. /**
  3661. * Creates a plane from three points
  3662. * @param point1 point used to create the plane
  3663. * @param point2 point used to create the plane
  3664. * @param point3 point used to create the plane
  3665. * @returns a new Plane defined by the three given points.
  3666. */
  3667. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Creates a plane from an origin point and a normal
  3670. * @param origin origin of the plane to be constructed
  3671. * @param normal normal of the plane to be constructed
  3672. * @returns a new Plane the normal vector to this plane at the given origin point.
  3673. * Note : the vector "normal" is updated because normalized.
  3674. */
  3675. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3676. /**
  3677. * Calculates the distance from a plane and a point
  3678. * @param origin origin of the plane to be constructed
  3679. * @param normal normal of the plane to be constructed
  3680. * @param point point to calculate distance to
  3681. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3682. */
  3683. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3684. }
  3685. /**
  3686. * Class used to represent a viewport on screen
  3687. */
  3688. export class Viewport {
  3689. /** viewport left coordinate */
  3690. x: number;
  3691. /** viewport top coordinate */
  3692. y: number;
  3693. /**viewport width */
  3694. width: number;
  3695. /** viewport height */
  3696. height: number;
  3697. /**
  3698. * Creates a Viewport object located at (x, y) and sized (width, height)
  3699. * @param x defines viewport left coordinate
  3700. * @param y defines viewport top coordinate
  3701. * @param width defines the viewport width
  3702. * @param height defines the viewport height
  3703. */
  3704. constructor(
  3705. /** viewport left coordinate */
  3706. x: number,
  3707. /** viewport top coordinate */
  3708. y: number,
  3709. /**viewport width */
  3710. width: number,
  3711. /** viewport height */
  3712. height: number);
  3713. /**
  3714. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3715. * @param renderWidth defines the rendering width
  3716. * @param renderHeight defines the rendering height
  3717. * @returns a new Viewport
  3718. */
  3719. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3720. /**
  3721. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3722. * @param renderWidth defines the rendering width
  3723. * @param renderHeight defines the rendering height
  3724. * @param ref defines the target viewport
  3725. * @returns the current viewport
  3726. */
  3727. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3728. /**
  3729. * Returns a new Viewport copied from the current one
  3730. * @returns a new Viewport
  3731. */
  3732. clone(): Viewport;
  3733. }
  3734. /**
  3735. * Reprasents a camera frustum
  3736. */
  3737. export class Frustum {
  3738. /**
  3739. * Gets the planes representing the frustum
  3740. * @param transform matrix to be applied to the returned planes
  3741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3742. */
  3743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3744. /**
  3745. * Gets the near frustum plane transformed by the transform matrix
  3746. * @param transform transformation matrix to be applied to the resulting frustum plane
  3747. * @param frustumPlane the resuling frustum plane
  3748. */
  3749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3750. /**
  3751. * Gets the far frustum plane transformed by the transform matrix
  3752. * @param transform transformation matrix to be applied to the resulting frustum plane
  3753. * @param frustumPlane the resuling frustum plane
  3754. */
  3755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3756. /**
  3757. * Gets the left frustum plane transformed by the transform matrix
  3758. * @param transform transformation matrix to be applied to the resulting frustum plane
  3759. * @param frustumPlane the resuling frustum plane
  3760. */
  3761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3762. /**
  3763. * Gets the right frustum plane transformed by the transform matrix
  3764. * @param transform transformation matrix to be applied to the resulting frustum plane
  3765. * @param frustumPlane the resuling frustum plane
  3766. */
  3767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3768. /**
  3769. * Gets the top frustum plane transformed by the transform matrix
  3770. * @param transform transformation matrix to be applied to the resulting frustum plane
  3771. * @param frustumPlane the resuling frustum plane
  3772. */
  3773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3774. /**
  3775. * Gets the bottom frustum plane transformed by the transform matrix
  3776. * @param transform transformation matrix to be applied to the resulting frustum plane
  3777. * @param frustumPlane the resuling frustum plane
  3778. */
  3779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3780. /**
  3781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3782. * @param transform transformation matrix to be applied to the resulting frustum planes
  3783. * @param frustumPlanes the resuling frustum planes
  3784. */
  3785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3786. }
  3787. /** Defines supported spaces */
  3788. export enum Space {
  3789. /** Local (object) space */
  3790. LOCAL = 0,
  3791. /** World space */
  3792. WORLD = 1,
  3793. /** Bone space */
  3794. BONE = 2
  3795. }
  3796. /** Defines the 3 main axes */
  3797. export class Axis {
  3798. /** X axis */
  3799. static X: Vector3;
  3800. /** Y axis */
  3801. static Y: Vector3;
  3802. /** Z axis */
  3803. static Z: Vector3;
  3804. }
  3805. /** Class used to represent a Bezier curve */
  3806. export class BezierCurve {
  3807. /**
  3808. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3809. * @param t defines the time
  3810. * @param x1 defines the left coordinate on X axis
  3811. * @param y1 defines the left coordinate on Y axis
  3812. * @param x2 defines the right coordinate on X axis
  3813. * @param y2 defines the right coordinate on Y axis
  3814. * @returns the interpolated value
  3815. */
  3816. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3817. }
  3818. /**
  3819. * Defines potential orientation for back face culling
  3820. */
  3821. export enum Orientation {
  3822. /**
  3823. * Clockwise
  3824. */
  3825. CW = 0,
  3826. /** Counter clockwise */
  3827. CCW = 1
  3828. }
  3829. /**
  3830. * Defines angle representation
  3831. */
  3832. export class Angle {
  3833. private _radians;
  3834. /**
  3835. * Creates an Angle object of "radians" radians (float).
  3836. * @param radians the angle in radians
  3837. */
  3838. constructor(radians: number);
  3839. /**
  3840. * Get value in degrees
  3841. * @returns the Angle value in degrees (float)
  3842. */
  3843. degrees(): number;
  3844. /**
  3845. * Get value in radians
  3846. * @returns the Angle value in radians (float)
  3847. */
  3848. radians(): number;
  3849. /**
  3850. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3851. * @param a defines first vector
  3852. * @param b defines second vector
  3853. * @returns a new Angle
  3854. */
  3855. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3856. /**
  3857. * Gets a new Angle object from the given float in radians
  3858. * @param radians defines the angle value in radians
  3859. * @returns a new Angle
  3860. */
  3861. static FromRadians(radians: number): Angle;
  3862. /**
  3863. * Gets a new Angle object from the given float in degrees
  3864. * @param degrees defines the angle value in degrees
  3865. * @returns a new Angle
  3866. */
  3867. static FromDegrees(degrees: number): Angle;
  3868. }
  3869. /**
  3870. * This represents an arc in a 2d space.
  3871. */
  3872. export class Arc2 {
  3873. /** Defines the start point of the arc */
  3874. startPoint: Vector2;
  3875. /** Defines the mid point of the arc */
  3876. midPoint: Vector2;
  3877. /** Defines the end point of the arc */
  3878. endPoint: Vector2;
  3879. /**
  3880. * Defines the center point of the arc.
  3881. */
  3882. centerPoint: Vector2;
  3883. /**
  3884. * Defines the radius of the arc.
  3885. */
  3886. radius: number;
  3887. /**
  3888. * Defines the angle of the arc (from mid point to end point).
  3889. */
  3890. angle: Angle;
  3891. /**
  3892. * Defines the start angle of the arc (from start point to middle point).
  3893. */
  3894. startAngle: Angle;
  3895. /**
  3896. * Defines the orientation of the arc (clock wise/counter clock wise).
  3897. */
  3898. orientation: Orientation;
  3899. /**
  3900. * Creates an Arc object from the three given points : start, middle and end.
  3901. * @param startPoint Defines the start point of the arc
  3902. * @param midPoint Defines the midlle point of the arc
  3903. * @param endPoint Defines the end point of the arc
  3904. */
  3905. constructor(
  3906. /** Defines the start point of the arc */
  3907. startPoint: Vector2,
  3908. /** Defines the mid point of the arc */
  3909. midPoint: Vector2,
  3910. /** Defines the end point of the arc */
  3911. endPoint: Vector2);
  3912. }
  3913. /**
  3914. * Represents a 2D path made up of multiple 2D points
  3915. */
  3916. export class Path2 {
  3917. private _points;
  3918. private _length;
  3919. /**
  3920. * If the path start and end point are the same
  3921. */
  3922. closed: boolean;
  3923. /**
  3924. * Creates a Path2 object from the starting 2D coordinates x and y.
  3925. * @param x the starting points x value
  3926. * @param y the starting points y value
  3927. */
  3928. constructor(x: number, y: number);
  3929. /**
  3930. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3931. * @param x the added points x value
  3932. * @param y the added points y value
  3933. * @returns the updated Path2.
  3934. */
  3935. addLineTo(x: number, y: number): Path2;
  3936. /**
  3937. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3938. * @param midX middle point x value
  3939. * @param midY middle point y value
  3940. * @param endX end point x value
  3941. * @param endY end point y value
  3942. * @param numberOfSegments (default: 36)
  3943. * @returns the updated Path2.
  3944. */
  3945. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3946. /**
  3947. * Closes the Path2.
  3948. * @returns the Path2.
  3949. */
  3950. close(): Path2;
  3951. /**
  3952. * Gets the sum of the distance between each sequential point in the path
  3953. * @returns the Path2 total length (float).
  3954. */
  3955. length(): number;
  3956. /**
  3957. * Gets the points which construct the path
  3958. * @returns the Path2 internal array of points.
  3959. */
  3960. getPoints(): Vector2[];
  3961. /**
  3962. * Retreives the point at the distance aways from the starting point
  3963. * @param normalizedLengthPosition the length along the path to retreive the point from
  3964. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3965. */
  3966. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3967. /**
  3968. * Creates a new path starting from an x and y position
  3969. * @param x starting x value
  3970. * @param y starting y value
  3971. * @returns a new Path2 starting at the coordinates (x, y).
  3972. */
  3973. static StartingAt(x: number, y: number): Path2;
  3974. }
  3975. /**
  3976. * Represents a 3D path made up of multiple 3D points
  3977. */
  3978. export class Path3D {
  3979. /**
  3980. * an array of Vector3, the curve axis of the Path3D
  3981. */
  3982. path: Vector3[];
  3983. private _curve;
  3984. private _distances;
  3985. private _tangents;
  3986. private _normals;
  3987. private _binormals;
  3988. private _raw;
  3989. /**
  3990. * new Path3D(path, normal, raw)
  3991. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3992. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3993. * @param path an array of Vector3, the curve axis of the Path3D
  3994. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3995. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3996. */
  3997. constructor(
  3998. /**
  3999. * an array of Vector3, the curve axis of the Path3D
  4000. */
  4001. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4002. /**
  4003. * Returns the Path3D array of successive Vector3 designing its curve.
  4004. * @returns the Path3D array of successive Vector3 designing its curve.
  4005. */
  4006. getCurve(): Vector3[];
  4007. /**
  4008. * Returns an array populated with tangent vectors on each Path3D curve point.
  4009. * @returns an array populated with tangent vectors on each Path3D curve point.
  4010. */
  4011. getTangents(): Vector3[];
  4012. /**
  4013. * Returns an array populated with normal vectors on each Path3D curve point.
  4014. * @returns an array populated with normal vectors on each Path3D curve point.
  4015. */
  4016. getNormals(): Vector3[];
  4017. /**
  4018. * Returns an array populated with binormal vectors on each Path3D curve point.
  4019. * @returns an array populated with binormal vectors on each Path3D curve point.
  4020. */
  4021. getBinormals(): Vector3[];
  4022. /**
  4023. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4024. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4025. */
  4026. getDistances(): number[];
  4027. /**
  4028. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4029. * @param path path which all values are copied into the curves points
  4030. * @param firstNormal which should be projected onto the curve
  4031. * @returns the same object updated.
  4032. */
  4033. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4034. private _compute;
  4035. private _getFirstNonNullVector;
  4036. private _getLastNonNullVector;
  4037. private _normalVector;
  4038. }
  4039. /**
  4040. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4041. * A Curve3 is designed from a series of successive Vector3.
  4042. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4043. */
  4044. export class Curve3 {
  4045. private _points;
  4046. private _length;
  4047. /**
  4048. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4049. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4050. * @param v1 (Vector3) the control point
  4051. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4052. * @param nbPoints (integer) the wanted number of points in the curve
  4053. * @returns the created Curve3
  4054. */
  4055. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4056. /**
  4057. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4058. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4059. * @param v1 (Vector3) the first control point
  4060. * @param v2 (Vector3) the second control point
  4061. * @param v3 (Vector3) the end point of the Cubic Bezier
  4062. * @param nbPoints (integer) the wanted number of points in the curve
  4063. * @returns the created Curve3
  4064. */
  4065. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4066. /**
  4067. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4068. * @param p1 (Vector3) the origin point of the Hermite Spline
  4069. * @param t1 (Vector3) the tangent vector at the origin point
  4070. * @param p2 (Vector3) the end point of the Hermite Spline
  4071. * @param t2 (Vector3) the tangent vector at the end point
  4072. * @param nbPoints (integer) the wanted number of points in the curve
  4073. * @returns the created Curve3
  4074. */
  4075. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4076. /**
  4077. * Returns a Curve3 object along a CatmullRom Spline curve :
  4078. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4079. * @param nbPoints (integer) the wanted number of points between each curve control points
  4080. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4081. * @returns the created Curve3
  4082. */
  4083. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4084. /**
  4085. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4086. * A Curve3 is designed from a series of successive Vector3.
  4087. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4088. * @param points points which make up the curve
  4089. */
  4090. constructor(points: Vector3[]);
  4091. /**
  4092. * @returns the Curve3 stored array of successive Vector3
  4093. */
  4094. getPoints(): Vector3[];
  4095. /**
  4096. * @returns the computed length (float) of the curve.
  4097. */
  4098. length(): number;
  4099. /**
  4100. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4101. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4102. * curveA and curveB keep unchanged.
  4103. * @param curve the curve to continue from this curve
  4104. * @returns the newly constructed curve
  4105. */
  4106. continue(curve: DeepImmutable<Curve3>): Curve3;
  4107. private _computeLength;
  4108. }
  4109. /**
  4110. * Contains position and normal vectors for a vertex
  4111. */
  4112. export class PositionNormalVertex {
  4113. /** the position of the vertex (defaut: 0,0,0) */
  4114. position: Vector3;
  4115. /** the normal of the vertex (defaut: 0,1,0) */
  4116. normal: Vector3;
  4117. /**
  4118. * Creates a PositionNormalVertex
  4119. * @param position the position of the vertex (defaut: 0,0,0)
  4120. * @param normal the normal of the vertex (defaut: 0,1,0)
  4121. */
  4122. constructor(
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position?: Vector3,
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal?: Vector3);
  4127. /**
  4128. * Clones the PositionNormalVertex
  4129. * @returns the cloned PositionNormalVertex
  4130. */
  4131. clone(): PositionNormalVertex;
  4132. }
  4133. /**
  4134. * Contains position, normal and uv vectors for a vertex
  4135. */
  4136. export class PositionNormalTextureVertex {
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position: Vector3;
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal: Vector3;
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv: Vector2;
  4143. /**
  4144. * Creates a PositionNormalTextureVertex
  4145. * @param position the position of the vertex (defaut: 0,0,0)
  4146. * @param normal the normal of the vertex (defaut: 0,1,0)
  4147. * @param uv the uv of the vertex (default: 0,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3,
  4154. /** the uv of the vertex (default: 0,0) */
  4155. uv?: Vector2);
  4156. /**
  4157. * Clones the PositionNormalTextureVertex
  4158. * @returns the cloned PositionNormalTextureVertex
  4159. */
  4160. clone(): PositionNormalTextureVertex;
  4161. }
  4162. /**
  4163. * @hidden
  4164. */
  4165. export class Tmp {
  4166. static Color3: Color3[];
  4167. static Color4: Color4[];
  4168. static Vector2: Vector2[];
  4169. static Vector3: Vector3[];
  4170. static Vector4: Vector4[];
  4171. static Quaternion: Quaternion[];
  4172. static Matrix: Matrix[];
  4173. }
  4174. }
  4175. declare module BABYLON {
  4176. /**
  4177. * Class used to enable access to offline support
  4178. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4179. */
  4180. export interface IOfflineProvider {
  4181. /**
  4182. * Gets a boolean indicating if scene must be saved in the database
  4183. */
  4184. enableSceneOffline: boolean;
  4185. /**
  4186. * Gets a boolean indicating if textures must be saved in the database
  4187. */
  4188. enableTexturesOffline: boolean;
  4189. /**
  4190. * Open the offline support and make it available
  4191. * @param successCallback defines the callback to call on success
  4192. * @param errorCallback defines the callback to call on error
  4193. */
  4194. open(successCallback: () => void, errorCallback: () => void): void;
  4195. /**
  4196. * Loads an image from the offline support
  4197. * @param url defines the url to load from
  4198. * @param image defines the target DOM image
  4199. */
  4200. loadImage(url: string, image: HTMLImageElement): void;
  4201. /**
  4202. * Loads a file from offline support
  4203. * @param url defines the URL to load from
  4204. * @param sceneLoaded defines a callback to call on success
  4205. * @param progressCallBack defines a callback to call when progress changed
  4206. * @param errorCallback defines a callback to call on error
  4207. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4208. */
  4209. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4210. }
  4211. }
  4212. declare module BABYLON {
  4213. /**
  4214. * A class serves as a medium between the observable and its observers
  4215. */
  4216. export class EventState {
  4217. /**
  4218. * Create a new EventState
  4219. * @param mask defines the mask associated with this state
  4220. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4221. * @param target defines the original target of the state
  4222. * @param currentTarget defines the current target of the state
  4223. */
  4224. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4225. /**
  4226. * Initialize the current event state
  4227. * @param mask defines the mask associated with this state
  4228. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4229. * @param target defines the original target of the state
  4230. * @param currentTarget defines the current target of the state
  4231. * @returns the current event state
  4232. */
  4233. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4234. /**
  4235. * An Observer can set this property to true to prevent subsequent observers of being notified
  4236. */
  4237. skipNextObservers: boolean;
  4238. /**
  4239. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4240. */
  4241. mask: number;
  4242. /**
  4243. * The object that originally notified the event
  4244. */
  4245. target?: any;
  4246. /**
  4247. * The current object in the bubbling phase
  4248. */
  4249. currentTarget?: any;
  4250. /**
  4251. * This will be populated with the return value of the last function that was executed.
  4252. * If it is the first function in the callback chain it will be the event data.
  4253. */
  4254. lastReturnValue?: any;
  4255. }
  4256. /**
  4257. * Represent an Observer registered to a given Observable object.
  4258. */
  4259. export class Observer<T> {
  4260. /**
  4261. * Defines the callback to call when the observer is notified
  4262. */
  4263. callback: (eventData: T, eventState: EventState) => void;
  4264. /**
  4265. * Defines the mask of the observer (used to filter notifications)
  4266. */
  4267. mask: number;
  4268. /**
  4269. * Defines the current scope used to restore the JS context
  4270. */
  4271. scope: any;
  4272. /** @hidden */ willBeUnregistered: boolean;
  4273. /**
  4274. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4275. */
  4276. unregisterOnNextCall: boolean;
  4277. /**
  4278. * Creates a new observer
  4279. * @param callback defines the callback to call when the observer is notified
  4280. * @param mask defines the mask of the observer (used to filter notifications)
  4281. * @param scope defines the current scope used to restore the JS context
  4282. */
  4283. constructor(
  4284. /**
  4285. * Defines the callback to call when the observer is notified
  4286. */
  4287. callback: (eventData: T, eventState: EventState) => void,
  4288. /**
  4289. * Defines the mask of the observer (used to filter notifications)
  4290. */
  4291. mask: number,
  4292. /**
  4293. * Defines the current scope used to restore the JS context
  4294. */
  4295. scope?: any);
  4296. }
  4297. /**
  4298. * Represent a list of observers registered to multiple Observables object.
  4299. */
  4300. export class MultiObserver<T> {
  4301. private _observers;
  4302. private _observables;
  4303. /**
  4304. * Release associated resources
  4305. */
  4306. dispose(): void;
  4307. /**
  4308. * Raise a callback when one of the observable will notify
  4309. * @param observables defines a list of observables to watch
  4310. * @param callback defines the callback to call on notification
  4311. * @param mask defines the mask used to filter notifications
  4312. * @param scope defines the current scope used to restore the JS context
  4313. * @returns the new MultiObserver
  4314. */
  4315. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4316. }
  4317. /**
  4318. * The Observable class is a simple implementation of the Observable pattern.
  4319. *
  4320. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4321. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4322. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4323. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4324. */
  4325. export class Observable<T> {
  4326. private _observers;
  4327. private _eventState;
  4328. private _onObserverAdded;
  4329. /**
  4330. * Creates a new observable
  4331. * @param onObserverAdded defines a callback to call when a new observer is added
  4332. */
  4333. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4334. /**
  4335. * Create a new Observer with the specified callback
  4336. * @param callback the callback that will be executed for that Observer
  4337. * @param mask the mask used to filter observers
  4338. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4339. * @param scope optional scope for the callback to be called from
  4340. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4341. * @returns the new observer created for the callback
  4342. */
  4343. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4344. /**
  4345. * Create a new Observer with the specified callback and unregisters after the next notification
  4346. * @param callback the callback that will be executed for that Observer
  4347. * @returns the new observer created for the callback
  4348. */
  4349. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4350. /**
  4351. * Remove an Observer from the Observable object
  4352. * @param observer the instance of the Observer to remove
  4353. * @returns false if it doesn't belong to this Observable
  4354. */
  4355. remove(observer: Nullable<Observer<T>>): boolean;
  4356. /**
  4357. * Remove a callback from the Observable object
  4358. * @param callback the callback to remove
  4359. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4360. * @returns false if it doesn't belong to this Observable
  4361. */
  4362. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4363. private _deferUnregister;
  4364. private _remove;
  4365. /**
  4366. * Moves the observable to the top of the observer list making it get called first when notified
  4367. * @param observer the observer to move
  4368. */
  4369. makeObserverTopPriority(observer: Observer<T>): void;
  4370. /**
  4371. * Moves the observable to the bottom of the observer list making it get called last when notified
  4372. * @param observer the observer to move
  4373. */
  4374. makeObserverBottomPriority(observer: Observer<T>): void;
  4375. /**
  4376. * Notify all Observers by calling their respective callback with the given data
  4377. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4378. * @param eventData defines the data to send to all observers
  4379. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4380. * @param target defines the original target of the state
  4381. * @param currentTarget defines the current target of the state
  4382. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4383. */
  4384. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4385. /**
  4386. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4387. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4388. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4389. * and it is crucial that all callbacks will be executed.
  4390. * The order of the callbacks is kept, callbacks are not executed parallel.
  4391. *
  4392. * @param eventData The data to be sent to each callback
  4393. * @param mask is used to filter observers defaults to -1
  4394. * @param target defines the callback target (see EventState)
  4395. * @param currentTarget defines he current object in the bubbling phase
  4396. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4397. */
  4398. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4399. /**
  4400. * Notify a specific observer
  4401. * @param observer defines the observer to notify
  4402. * @param eventData defines the data to be sent to each callback
  4403. * @param mask is used to filter observers defaults to -1
  4404. */
  4405. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4406. /**
  4407. * Gets a boolean indicating if the observable has at least one observer
  4408. * @returns true is the Observable has at least one Observer registered
  4409. */
  4410. hasObservers(): boolean;
  4411. /**
  4412. * Clear the list of observers
  4413. */
  4414. clear(): void;
  4415. /**
  4416. * Clone the current observable
  4417. * @returns a new observable
  4418. */
  4419. clone(): Observable<T>;
  4420. /**
  4421. * Does this observable handles observer registered with a given mask
  4422. * @param mask defines the mask to be tested
  4423. * @return whether or not one observer registered with the given mask is handeled
  4424. **/
  4425. hasSpecificMask(mask?: number): boolean;
  4426. }
  4427. }
  4428. declare module BABYLON {
  4429. /**
  4430. * Class used to help managing file picking and drag'n'drop
  4431. * File Storage
  4432. */
  4433. export class FilesInputStore {
  4434. /**
  4435. * List of files ready to be loaded
  4436. */
  4437. static FilesToLoad: {
  4438. [key: string]: File;
  4439. };
  4440. }
  4441. }
  4442. declare module BABYLON {
  4443. /** Defines the cross module used constants to avoid circular dependncies */
  4444. export class Constants {
  4445. /** Defines that alpha blending is disabled */
  4446. static readonly ALPHA_DISABLE: number;
  4447. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4448. static readonly ALPHA_ADD: number;
  4449. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4450. static readonly ALPHA_COMBINE: number;
  4451. /** Defines that alpha blending to DEST - SRC * DEST */
  4452. static readonly ALPHA_SUBTRACT: number;
  4453. /** Defines that alpha blending to SRC * DEST */
  4454. static readonly ALPHA_MULTIPLY: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4456. static readonly ALPHA_MAXIMIZED: number;
  4457. /** Defines that alpha blending to SRC + DEST */
  4458. static readonly ALPHA_ONEONE: number;
  4459. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4460. static readonly ALPHA_PREMULTIPLIED: number;
  4461. /**
  4462. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4463. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4464. */
  4465. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4466. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4467. static readonly ALPHA_INTERPOLATE: number;
  4468. /**
  4469. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4470. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4471. */
  4472. static readonly ALPHA_SCREENMODE: number;
  4473. /** Defines that the ressource is not delayed*/
  4474. static readonly DELAYLOADSTATE_NONE: number;
  4475. /** Defines that the ressource was successfully delay loaded */
  4476. static readonly DELAYLOADSTATE_LOADED: number;
  4477. /** Defines that the ressource is currently delay loading */
  4478. static readonly DELAYLOADSTATE_LOADING: number;
  4479. /** Defines that the ressource is delayed and has not started loading */
  4480. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4481. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4482. static readonly NEVER: number;
  4483. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4484. static readonly ALWAYS: number;
  4485. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4486. static readonly LESS: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4488. static readonly EQUAL: number;
  4489. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4490. static readonly LEQUAL: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4492. static readonly GREATER: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4494. static readonly GEQUAL: number;
  4495. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4496. static readonly NOTEQUAL: number;
  4497. /** Passed to stencilOperation to specify that stencil value must be kept */
  4498. static readonly KEEP: number;
  4499. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4500. static readonly REPLACE: number;
  4501. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4502. static readonly INCR: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4504. static readonly DECR: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4506. static readonly INVERT: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4508. static readonly INCR_WRAP: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4510. static readonly DECR_WRAP: number;
  4511. /** Texture is not repeating outside of 0..1 UVs */
  4512. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4513. /** Texture is repeating outside of 0..1 UVs */
  4514. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4515. /** Texture is repeating and mirrored */
  4516. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4517. /** ALPHA */
  4518. static readonly TEXTUREFORMAT_ALPHA: number;
  4519. /** LUMINANCE */
  4520. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4521. /** LUMINANCE_ALPHA */
  4522. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4523. /** RGB */
  4524. static readonly TEXTUREFORMAT_RGB: number;
  4525. /** RGBA */
  4526. static readonly TEXTUREFORMAT_RGBA: number;
  4527. /** RED */
  4528. static readonly TEXTUREFORMAT_RED: number;
  4529. /** RED (2nd reference) */
  4530. static readonly TEXTUREFORMAT_R: number;
  4531. /** RG */
  4532. static readonly TEXTUREFORMAT_RG: number;
  4533. /** RED_INTEGER */
  4534. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4535. /** RED_INTEGER (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4537. /** RG_INTEGER */
  4538. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4539. /** RGB_INTEGER */
  4540. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4541. /** RGBA_INTEGER */
  4542. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4543. /** UNSIGNED_BYTE */
  4544. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4545. /** UNSIGNED_BYTE (2nd reference) */
  4546. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4547. /** FLOAT */
  4548. static readonly TEXTURETYPE_FLOAT: number;
  4549. /** HALF_FLOAT */
  4550. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4551. /** BYTE */
  4552. static readonly TEXTURETYPE_BYTE: number;
  4553. /** SHORT */
  4554. static readonly TEXTURETYPE_SHORT: number;
  4555. /** UNSIGNED_SHORT */
  4556. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4557. /** INT */
  4558. static readonly TEXTURETYPE_INT: number;
  4559. /** UNSIGNED_INT */
  4560. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4561. /** UNSIGNED_SHORT_4_4_4_4 */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4563. /** UNSIGNED_SHORT_5_5_5_1 */
  4564. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4565. /** UNSIGNED_SHORT_5_6_5 */
  4566. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4567. /** UNSIGNED_INT_2_10_10_10_REV */
  4568. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4569. /** UNSIGNED_INT_24_8 */
  4570. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4571. /** UNSIGNED_INT_10F_11F_11F_REV */
  4572. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4573. /** UNSIGNED_INT_5_9_9_9_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4575. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4576. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4577. /** nearest is mag = nearest and min = nearest and mip = linear */
  4578. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4579. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4580. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4581. /** Trilinear is mag = linear and min = linear and mip = linear */
  4582. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4589. /** mag = nearest and min = nearest and mip = nearest */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4591. /** mag = nearest and min = linear and mip = nearest */
  4592. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4593. /** mag = nearest and min = linear and mip = linear */
  4594. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = linear and mip = none */
  4596. static readonly TEXTURE_NEAREST_LINEAR: number;
  4597. /** mag = nearest and min = nearest and mip = none */
  4598. static readonly TEXTURE_NEAREST_NEAREST: number;
  4599. /** mag = linear and min = nearest and mip = nearest */
  4600. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4601. /** mag = linear and min = nearest and mip = linear */
  4602. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4603. /** mag = linear and min = linear and mip = none */
  4604. static readonly TEXTURE_LINEAR_LINEAR: number;
  4605. /** mag = linear and min = nearest and mip = none */
  4606. static readonly TEXTURE_LINEAR_NEAREST: number;
  4607. /** Explicit coordinates mode */
  4608. static readonly TEXTURE_EXPLICIT_MODE: number;
  4609. /** Spherical coordinates mode */
  4610. static readonly TEXTURE_SPHERICAL_MODE: number;
  4611. /** Planar coordinates mode */
  4612. static readonly TEXTURE_PLANAR_MODE: number;
  4613. /** Cubic coordinates mode */
  4614. static readonly TEXTURE_CUBIC_MODE: number;
  4615. /** Projection coordinates mode */
  4616. static readonly TEXTURE_PROJECTION_MODE: number;
  4617. /** Skybox coordinates mode */
  4618. static readonly TEXTURE_SKYBOX_MODE: number;
  4619. /** Inverse Cubic coordinates mode */
  4620. static readonly TEXTURE_INVCUBIC_MODE: number;
  4621. /** Equirectangular coordinates mode */
  4622. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4623. /** Equirectangular Fixed coordinates mode */
  4624. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4625. /** Equirectangular Fixed Mirrored coordinates mode */
  4626. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4627. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4628. static readonly SCALEMODE_FLOOR: number;
  4629. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4630. static readonly SCALEMODE_NEAREST: number;
  4631. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4632. static readonly SCALEMODE_CEILING: number;
  4633. /**
  4634. * The dirty texture flag value
  4635. */
  4636. static readonly MATERIAL_TextureDirtyFlag: number;
  4637. /**
  4638. * The dirty light flag value
  4639. */
  4640. static readonly MATERIAL_LightDirtyFlag: number;
  4641. /**
  4642. * The dirty fresnel flag value
  4643. */
  4644. static readonly MATERIAL_FresnelDirtyFlag: number;
  4645. /**
  4646. * The dirty attribute flag value
  4647. */
  4648. static readonly MATERIAL_AttributesDirtyFlag: number;
  4649. /**
  4650. * The dirty misc flag value
  4651. */
  4652. static readonly MATERIAL_MiscDirtyFlag: number;
  4653. /**
  4654. * The all dirty flag value
  4655. */
  4656. static readonly MATERIAL_AllDirtyFlag: number;
  4657. /**
  4658. * Returns the triangle fill mode
  4659. */
  4660. static readonly MATERIAL_TriangleFillMode: number;
  4661. /**
  4662. * Returns the wireframe mode
  4663. */
  4664. static readonly MATERIAL_WireFrameFillMode: number;
  4665. /**
  4666. * Returns the point fill mode
  4667. */
  4668. static readonly MATERIAL_PointFillMode: number;
  4669. /**
  4670. * Returns the point list draw mode
  4671. */
  4672. static readonly MATERIAL_PointListDrawMode: number;
  4673. /**
  4674. * Returns the line list draw mode
  4675. */
  4676. static readonly MATERIAL_LineListDrawMode: number;
  4677. /**
  4678. * Returns the line loop draw mode
  4679. */
  4680. static readonly MATERIAL_LineLoopDrawMode: number;
  4681. /**
  4682. * Returns the line strip draw mode
  4683. */
  4684. static readonly MATERIAL_LineStripDrawMode: number;
  4685. /**
  4686. * Returns the triangle strip draw mode
  4687. */
  4688. static readonly MATERIAL_TriangleStripDrawMode: number;
  4689. /**
  4690. * Returns the triangle fan draw mode
  4691. */
  4692. static readonly MATERIAL_TriangleFanDrawMode: number;
  4693. /**
  4694. * Stores the clock-wise side orientation
  4695. */
  4696. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4697. /**
  4698. * Stores the counter clock-wise side orientation
  4699. */
  4700. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4701. /**
  4702. * Nothing
  4703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4704. */
  4705. static readonly ACTION_NothingTrigger: number;
  4706. /**
  4707. * On pick
  4708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4709. */
  4710. static readonly ACTION_OnPickTrigger: number;
  4711. /**
  4712. * On left pick
  4713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4714. */
  4715. static readonly ACTION_OnLeftPickTrigger: number;
  4716. /**
  4717. * On right pick
  4718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4719. */
  4720. static readonly ACTION_OnRightPickTrigger: number;
  4721. /**
  4722. * On center pick
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnCenterPickTrigger: number;
  4726. /**
  4727. * On pick down
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnPickDownTrigger: number;
  4731. /**
  4732. * On double pick
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnDoublePickTrigger: number;
  4736. /**
  4737. * On pick up
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPickUpTrigger: number;
  4741. /**
  4742. * On pick out.
  4743. * This trigger will only be raised if you also declared a OnPickDown
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickOutTrigger: number;
  4747. /**
  4748. * On long press
  4749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4750. */
  4751. static readonly ACTION_OnLongPressTrigger: number;
  4752. /**
  4753. * On pointer over
  4754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4755. */
  4756. static readonly ACTION_OnPointerOverTrigger: number;
  4757. /**
  4758. * On pointer out
  4759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4760. */
  4761. static readonly ACTION_OnPointerOutTrigger: number;
  4762. /**
  4763. * On every frame
  4764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4765. */
  4766. static readonly ACTION_OnEveryFrameTrigger: number;
  4767. /**
  4768. * On intersection enter
  4769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4770. */
  4771. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4772. /**
  4773. * On intersection exit
  4774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4775. */
  4776. static readonly ACTION_OnIntersectionExitTrigger: number;
  4777. /**
  4778. * On key down
  4779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4780. */
  4781. static readonly ACTION_OnKeyDownTrigger: number;
  4782. /**
  4783. * On key up
  4784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4785. */
  4786. static readonly ACTION_OnKeyUpTrigger: number;
  4787. /**
  4788. * Billboard mode will only apply to Y axis
  4789. */
  4790. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4791. /**
  4792. * Billboard mode will apply to all axes
  4793. */
  4794. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4795. /**
  4796. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4797. */
  4798. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4799. /**
  4800. * Gets or sets base Assets URL
  4801. */
  4802. static readonly PARTICLES_BaseAssetsUrl: string;
  4803. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4804. * Test order :
  4805. * Is the bounding sphere outside the frustum ?
  4806. * If not, are the bounding box vertices outside the frustum ?
  4807. * It not, then the cullable object is in the frustum.
  4808. */
  4809. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4810. /** Culling strategy : Bounding Sphere Only.
  4811. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4812. * It's also less accurate than the standard because some not visible objects can still be selected.
  4813. * Test : is the bounding sphere outside the frustum ?
  4814. * If not, then the cullable object is in the frustum.
  4815. */
  4816. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4817. /** Culling strategy : Optimistic Inclusion.
  4818. * This in an inclusion test first, then the standard exclusion test.
  4819. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4820. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4821. * Anyway, it's as accurate as the standard strategy.
  4822. * Test :
  4823. * Is the cullable object bounding sphere center in the frustum ?
  4824. * If not, apply the default culling strategy.
  4825. */
  4826. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4827. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4828. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4829. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4830. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4831. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4832. * Test :
  4833. * Is the cullable object bounding sphere center in the frustum ?
  4834. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4835. */
  4836. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4837. /**
  4838. * No logging while loading
  4839. */
  4840. static readonly SCENELOADER_NO_LOGGING: number;
  4841. /**
  4842. * Minimal logging while loading
  4843. */
  4844. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4845. /**
  4846. * Summary logging while loading
  4847. */
  4848. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4849. /**
  4850. * Detailled logging while loading
  4851. */
  4852. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4853. }
  4854. }
  4855. declare module BABYLON {
  4856. /**
  4857. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4858. * Babylon.js
  4859. */
  4860. export class DomManagement {
  4861. /**
  4862. * Checks if the window object exists
  4863. * @returns true if the window object exists
  4864. */
  4865. static IsWindowObjectExist(): boolean;
  4866. /**
  4867. * Extracts text content from a DOM element hierarchy
  4868. * @param element defines the root element
  4869. * @returns a string
  4870. */
  4871. static GetDOMTextContent(element: HTMLElement): string;
  4872. }
  4873. }
  4874. declare module BABYLON {
  4875. /**
  4876. * Logger used througouht the application to allow configuration of
  4877. * the log level required for the messages.
  4878. */
  4879. export class Logger {
  4880. /**
  4881. * No log
  4882. */
  4883. static readonly NoneLogLevel: number;
  4884. /**
  4885. * Only message logs
  4886. */
  4887. static readonly MessageLogLevel: number;
  4888. /**
  4889. * Only warning logs
  4890. */
  4891. static readonly WarningLogLevel: number;
  4892. /**
  4893. * Only error logs
  4894. */
  4895. static readonly ErrorLogLevel: number;
  4896. /**
  4897. * All logs
  4898. */
  4899. static readonly AllLogLevel: number;
  4900. private static _LogCache;
  4901. /**
  4902. * Gets a value indicating the number of loading errors
  4903. * @ignorenaming
  4904. */
  4905. static errorsCount: number;
  4906. /**
  4907. * Callback called when a new log is added
  4908. */
  4909. static OnNewCacheEntry: (entry: string) => void;
  4910. private static _AddLogEntry;
  4911. private static _FormatMessage;
  4912. private static _LogDisabled;
  4913. private static _LogEnabled;
  4914. private static _WarnDisabled;
  4915. private static _WarnEnabled;
  4916. private static _ErrorDisabled;
  4917. private static _ErrorEnabled;
  4918. /**
  4919. * Log a message to the console
  4920. */
  4921. static Log: (message: string) => void;
  4922. /**
  4923. * Write a warning message to the console
  4924. */
  4925. static Warn: (message: string) => void;
  4926. /**
  4927. * Write an error message to the console
  4928. */
  4929. static Error: (message: string) => void;
  4930. /**
  4931. * Gets current log cache (list of logs)
  4932. */
  4933. static readonly LogCache: string;
  4934. /**
  4935. * Clears the log cache
  4936. */
  4937. static ClearLogCache(): void;
  4938. /**
  4939. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4940. */
  4941. static LogLevels: number;
  4942. }
  4943. }
  4944. declare module BABYLON {
  4945. /** @hidden */
  4946. export class _TypeStore {
  4947. /** @hidden */
  4948. static RegisteredTypes: {
  4949. [key: string]: Object;
  4950. };
  4951. /** @hidden */
  4952. static GetClass(fqdn: string): any;
  4953. }
  4954. }
  4955. declare module BABYLON {
  4956. /**
  4957. * Class containing a set of static utilities functions for deep copy.
  4958. */
  4959. export class DeepCopier {
  4960. /**
  4961. * Tries to copy an object by duplicating every property
  4962. * @param source defines the source object
  4963. * @param destination defines the target object
  4964. * @param doNotCopyList defines a list of properties to avoid
  4965. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4966. */
  4967. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4968. }
  4969. }
  4970. declare module BABYLON {
  4971. /**
  4972. * Class containing a set of static utilities functions for precision date
  4973. */
  4974. export class PrecisionDate {
  4975. /**
  4976. * Gets either window.performance.now() if supported or Date.now() else
  4977. */
  4978. static readonly Now: number;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /** @hidden */
  4983. export class _DevTools {
  4984. static WarnImport(name: string): string;
  4985. }
  4986. }
  4987. declare module BABYLON {
  4988. /**
  4989. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4990. */
  4991. export class WebRequest {
  4992. private _xhr;
  4993. /**
  4994. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4995. * i.e. when loading files, where the server/service expects an Authorization header
  4996. */
  4997. static CustomRequestHeaders: {
  4998. [key: string]: string;
  4999. };
  5000. /**
  5001. * Add callback functions in this array to update all the requests before they get sent to the network
  5002. */
  5003. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5004. private _injectCustomRequestHeaders;
  5005. /**
  5006. * Gets or sets a function to be called when loading progress changes
  5007. */
  5008. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5009. /**
  5010. * Returns client's state
  5011. */
  5012. readonly readyState: number;
  5013. /**
  5014. * Returns client's status
  5015. */
  5016. readonly status: number;
  5017. /**
  5018. * Returns client's status as a text
  5019. */
  5020. readonly statusText: string;
  5021. /**
  5022. * Returns client's response
  5023. */
  5024. readonly response: any;
  5025. /**
  5026. * Returns client's response url
  5027. */
  5028. readonly responseURL: string;
  5029. /**
  5030. * Returns client's response as text
  5031. */
  5032. readonly responseText: string;
  5033. /**
  5034. * Gets or sets the expected response type
  5035. */
  5036. responseType: XMLHttpRequestResponseType;
  5037. /** @hidden */
  5038. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5039. /** @hidden */
  5040. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5041. /**
  5042. * Cancels any network activity
  5043. */
  5044. abort(): void;
  5045. /**
  5046. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5047. * @param body defines an optional request body
  5048. */
  5049. send(body?: Document | BodyInit | null): void;
  5050. /**
  5051. * Sets the request method, request URL
  5052. * @param method defines the method to use (GET, POST, etc..)
  5053. * @param url defines the url to connect with
  5054. */
  5055. open(method: string, url: string): void;
  5056. }
  5057. }
  5058. declare module BABYLON {
  5059. /**
  5060. * Class used to evalaute queries containing `and` and `or` operators
  5061. */
  5062. export class AndOrNotEvaluator {
  5063. /**
  5064. * Evaluate a query
  5065. * @param query defines the query to evaluate
  5066. * @param evaluateCallback defines the callback used to filter result
  5067. * @returns true if the query matches
  5068. */
  5069. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5070. private static _HandleParenthesisContent;
  5071. private static _SimplifyNegation;
  5072. }
  5073. }
  5074. declare module BABYLON {
  5075. /**
  5076. * Class used to store custom tags
  5077. */
  5078. export class Tags {
  5079. /**
  5080. * Adds support for tags on the given object
  5081. * @param obj defines the object to use
  5082. */
  5083. static EnableFor(obj: any): void;
  5084. /**
  5085. * Removes tags support
  5086. * @param obj defines the object to use
  5087. */
  5088. static DisableFor(obj: any): void;
  5089. /**
  5090. * Gets a boolean indicating if the given object has tags
  5091. * @param obj defines the object to use
  5092. * @returns a boolean
  5093. */
  5094. static HasTags(obj: any): boolean;
  5095. /**
  5096. * Gets the tags available on a given object
  5097. * @param obj defines the object to use
  5098. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5099. * @returns the tags
  5100. */
  5101. static GetTags(obj: any, asString?: boolean): any;
  5102. /**
  5103. * Adds tags to an object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5106. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5107. */
  5108. static AddTagsTo(obj: any, tagsString: string): void;
  5109. /**
  5110. * @hidden
  5111. */ private static _AddTagTo(obj: any, tag: string): void;
  5112. /**
  5113. * Removes specific tags from a specific object
  5114. * @param obj defines the object to use
  5115. * @param tagsString defines the tags to remove
  5116. */
  5117. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5118. /**
  5119. * @hidden
  5120. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5121. /**
  5122. * Defines if tags hosted on an object match a given query
  5123. * @param obj defines the object to use
  5124. * @param tagsQuery defines the tag query
  5125. * @returns a boolean
  5126. */
  5127. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5128. }
  5129. }
  5130. declare module BABYLON {
  5131. /**
  5132. * Manages the defines for the Material
  5133. */
  5134. export class MaterialDefines {
  5135. private _keys;
  5136. private _isDirty;
  5137. /** @hidden */ renderId: number;
  5138. /** @hidden */ areLightsDirty: boolean;
  5139. /** @hidden */ areAttributesDirty: boolean;
  5140. /** @hidden */ areTexturesDirty: boolean;
  5141. /** @hidden */ areFresnelDirty: boolean;
  5142. /** @hidden */ areMiscDirty: boolean;
  5143. /** @hidden */ areImageProcessingDirty: boolean;
  5144. /** @hidden */ normals: boolean;
  5145. /** @hidden */ uvs: boolean;
  5146. /** @hidden */ needNormals: boolean;
  5147. /** @hidden */ needUVs: boolean;
  5148. /**
  5149. * Specifies if the material needs to be re-calculated
  5150. */
  5151. readonly isDirty: boolean;
  5152. /**
  5153. * Marks the material to indicate that it has been re-calculated
  5154. */
  5155. markAsProcessed(): void;
  5156. /**
  5157. * Marks the material to indicate that it needs to be re-calculated
  5158. */
  5159. markAsUnprocessed(): void;
  5160. /**
  5161. * Marks the material to indicate all of its defines need to be re-calculated
  5162. */
  5163. markAllAsDirty(): void;
  5164. /**
  5165. * Marks the material to indicate that image processing needs to be re-calculated
  5166. */
  5167. markAsImageProcessingDirty(): void;
  5168. /**
  5169. * Marks the material to indicate the lights need to be re-calculated
  5170. */
  5171. markAsLightDirty(): void;
  5172. /**
  5173. * Marks the attribute state as changed
  5174. */
  5175. markAsAttributesDirty(): void;
  5176. /**
  5177. * Marks the texture state as changed
  5178. */
  5179. markAsTexturesDirty(): void;
  5180. /**
  5181. * Marks the fresnel state as changed
  5182. */
  5183. markAsFresnelDirty(): void;
  5184. /**
  5185. * Marks the misc state as changed
  5186. */
  5187. markAsMiscDirty(): void;
  5188. /**
  5189. * Rebuilds the material defines
  5190. */
  5191. rebuild(): void;
  5192. /**
  5193. * Specifies if two material defines are equal
  5194. * @param other - A material define instance to compare to
  5195. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5196. */
  5197. isEqual(other: MaterialDefines): boolean;
  5198. /**
  5199. * Clones this instance's defines to another instance
  5200. * @param other - material defines to clone values to
  5201. */
  5202. cloneTo(other: MaterialDefines): void;
  5203. /**
  5204. * Resets the material define values
  5205. */
  5206. reset(): void;
  5207. /**
  5208. * Converts the material define values to a string
  5209. * @returns - String of material define information
  5210. */
  5211. toString(): string;
  5212. }
  5213. }
  5214. declare module BABYLON {
  5215. /**
  5216. * Class used to store and describe the pipeline context associated with an effect
  5217. */
  5218. export interface IPipelineContext {
  5219. /**
  5220. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5221. */
  5222. isAsync: boolean;
  5223. /**
  5224. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5225. */
  5226. isReady: boolean;
  5227. }
  5228. }
  5229. declare module BABYLON {
  5230. /**
  5231. * Class used to store gfx data (like WebGLBuffer)
  5232. */
  5233. export class DataBuffer {
  5234. /**
  5235. * Gets or sets the number of objects referencing this buffer
  5236. */
  5237. references: number;
  5238. /** Gets or sets the size of the underlying buffer */
  5239. capacity: number;
  5240. /**
  5241. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5242. */
  5243. is32Bits: boolean;
  5244. /**
  5245. * Gets the underlying buffer
  5246. */
  5247. readonly underlyingResource: any;
  5248. }
  5249. }
  5250. declare module BABYLON {
  5251. /**
  5252. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5253. */
  5254. export class PerformanceMonitor {
  5255. private _enabled;
  5256. private _rollingFrameTime;
  5257. private _lastFrameTimeMs;
  5258. /**
  5259. * constructor
  5260. * @param frameSampleSize The number of samples required to saturate the sliding window
  5261. */
  5262. constructor(frameSampleSize?: number);
  5263. /**
  5264. * Samples current frame
  5265. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5266. */
  5267. sampleFrame(timeMs?: number): void;
  5268. /**
  5269. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5270. */
  5271. readonly averageFrameTime: number;
  5272. /**
  5273. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5274. */
  5275. readonly averageFrameTimeVariance: number;
  5276. /**
  5277. * Returns the frame time of the most recent frame
  5278. */
  5279. readonly instantaneousFrameTime: number;
  5280. /**
  5281. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5282. */
  5283. readonly averageFPS: number;
  5284. /**
  5285. * Returns the average framerate in frames per second using the most recent frame time
  5286. */
  5287. readonly instantaneousFPS: number;
  5288. /**
  5289. * Returns true if enough samples have been taken to completely fill the sliding window
  5290. */
  5291. readonly isSaturated: boolean;
  5292. /**
  5293. * Enables contributions to the sliding window sample set
  5294. */
  5295. enable(): void;
  5296. /**
  5297. * Disables contributions to the sliding window sample set
  5298. * Samples will not be interpolated over the disabled period
  5299. */
  5300. disable(): void;
  5301. /**
  5302. * Returns true if sampling is enabled
  5303. */
  5304. readonly isEnabled: boolean;
  5305. /**
  5306. * Resets performance monitor
  5307. */
  5308. reset(): void;
  5309. }
  5310. /**
  5311. * RollingAverage
  5312. *
  5313. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5314. */
  5315. export class RollingAverage {
  5316. /**
  5317. * Current average
  5318. */
  5319. average: number;
  5320. /**
  5321. * Current variance
  5322. */
  5323. variance: number;
  5324. protected _samples: Array<number>;
  5325. protected _sampleCount: number;
  5326. protected _pos: number;
  5327. protected _m2: number;
  5328. /**
  5329. * constructor
  5330. * @param length The number of samples required to saturate the sliding window
  5331. */
  5332. constructor(length: number);
  5333. /**
  5334. * Adds a sample to the sample set
  5335. * @param v The sample value
  5336. */
  5337. add(v: number): void;
  5338. /**
  5339. * Returns previously added values or null if outside of history or outside the sliding window domain
  5340. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5341. * @return Value previously recorded with add() or null if outside of range
  5342. */
  5343. history(i: number): number;
  5344. /**
  5345. * Returns true if enough samples have been taken to completely fill the sliding window
  5346. * @return true if sample-set saturated
  5347. */
  5348. isSaturated(): boolean;
  5349. /**
  5350. * Resets the rolling average (equivalent to 0 samples taken so far)
  5351. */
  5352. reset(): void;
  5353. /**
  5354. * Wraps a value around the sample range boundaries
  5355. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5356. * @return Wrapped position in sample range
  5357. */
  5358. protected _wrapPosition(i: number): number;
  5359. }
  5360. }
  5361. declare module BABYLON {
  5362. /**
  5363. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5364. * The underlying implementation relies on an associative array to ensure the best performances.
  5365. * The value can be anything including 'null' but except 'undefined'
  5366. */
  5367. export class StringDictionary<T> {
  5368. /**
  5369. * This will clear this dictionary and copy the content from the 'source' one.
  5370. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5371. * @param source the dictionary to take the content from and copy to this dictionary
  5372. */
  5373. copyFrom(source: StringDictionary<T>): void;
  5374. /**
  5375. * Get a value based from its key
  5376. * @param key the given key to get the matching value from
  5377. * @return the value if found, otherwise undefined is returned
  5378. */
  5379. get(key: string): T | undefined;
  5380. /**
  5381. * Get a value from its key or add it if it doesn't exist.
  5382. * This method will ensure you that a given key/data will be present in the dictionary.
  5383. * @param key the given key to get the matching value from
  5384. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5385. * The factory will only be invoked if there's no data for the given key.
  5386. * @return the value corresponding to the key.
  5387. */
  5388. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5389. /**
  5390. * Get a value from its key if present in the dictionary otherwise add it
  5391. * @param key the key to get the value from
  5392. * @param val if there's no such key/value pair in the dictionary add it with this value
  5393. * @return the value corresponding to the key
  5394. */
  5395. getOrAdd(key: string, val: T): T;
  5396. /**
  5397. * Check if there's a given key in the dictionary
  5398. * @param key the key to check for
  5399. * @return true if the key is present, false otherwise
  5400. */
  5401. contains(key: string): boolean;
  5402. /**
  5403. * Add a new key and its corresponding value
  5404. * @param key the key to add
  5405. * @param value the value corresponding to the key
  5406. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5407. */
  5408. add(key: string, value: T): boolean;
  5409. /**
  5410. * Update a specific value associated to a key
  5411. * @param key defines the key to use
  5412. * @param value defines the value to store
  5413. * @returns true if the value was updated (or false if the key was not found)
  5414. */
  5415. set(key: string, value: T): boolean;
  5416. /**
  5417. * Get the element of the given key and remove it from the dictionary
  5418. * @param key defines the key to search
  5419. * @returns the value associated with the key or null if not found
  5420. */
  5421. getAndRemove(key: string): Nullable<T>;
  5422. /**
  5423. * Remove a key/value from the dictionary.
  5424. * @param key the key to remove
  5425. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5426. */
  5427. remove(key: string): boolean;
  5428. /**
  5429. * Clear the whole content of the dictionary
  5430. */
  5431. clear(): void;
  5432. /**
  5433. * Gets the current count
  5434. */
  5435. readonly count: number;
  5436. /**
  5437. * Execute a callback on each key/val of the dictionary.
  5438. * Note that you can remove any element in this dictionary in the callback implementation
  5439. * @param callback the callback to execute on a given key/value pair
  5440. */
  5441. forEach(callback: (key: string, val: T) => void): void;
  5442. /**
  5443. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5444. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5445. * Note that you can remove any element in this dictionary in the callback implementation
  5446. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5447. * @returns the first item
  5448. */
  5449. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5450. private _count;
  5451. private _data;
  5452. }
  5453. }
  5454. declare module BABYLON {
  5455. /**
  5456. * Helper class that provides a small promise polyfill
  5457. */
  5458. export class PromisePolyfill {
  5459. /**
  5460. * Static function used to check if the polyfill is required
  5461. * If this is the case then the function will inject the polyfill to window.Promise
  5462. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5463. */
  5464. static Apply(force?: boolean): void;
  5465. }
  5466. }
  5467. declare module BABYLON {
  5468. /**
  5469. * Class used to store data that will be store in GPU memory
  5470. */
  5471. export class Buffer {
  5472. private _engine;
  5473. private _buffer;
  5474. /** @hidden */ data: Nullable<DataArray>;
  5475. private _updatable;
  5476. private _instanced;
  5477. /**
  5478. * Gets the byte stride.
  5479. */
  5480. readonly byteStride: number;
  5481. /**
  5482. * Constructor
  5483. * @param engine the engine
  5484. * @param data the data to use for this buffer
  5485. * @param updatable whether the data is updatable
  5486. * @param stride the stride (optional)
  5487. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5488. * @param instanced whether the buffer is instanced (optional)
  5489. * @param useBytes set to true if the stride in in bytes (optional)
  5490. */
  5491. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5492. /**
  5493. * Create a new VertexBuffer based on the current buffer
  5494. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5495. * @param offset defines offset in the buffer (0 by default)
  5496. * @param size defines the size in floats of attributes (position is 3 for instance)
  5497. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5498. * @param instanced defines if the vertex buffer contains indexed data
  5499. * @param useBytes defines if the offset and stride are in bytes
  5500. * @returns the new vertex buffer
  5501. */
  5502. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5503. /**
  5504. * Gets a boolean indicating if the Buffer is updatable?
  5505. * @returns true if the buffer is updatable
  5506. */
  5507. isUpdatable(): boolean;
  5508. /**
  5509. * Gets current buffer's data
  5510. * @returns a DataArray or null
  5511. */
  5512. getData(): Nullable<DataArray>;
  5513. /**
  5514. * Gets underlying native buffer
  5515. * @returns underlying native buffer
  5516. */
  5517. getBuffer(): Nullable<DataBuffer>;
  5518. /**
  5519. * Gets the stride in float32 units (i.e. byte stride / 4).
  5520. * May not be an integer if the byte stride is not divisible by 4.
  5521. * DEPRECATED. Use byteStride instead.
  5522. * @returns the stride in float32 units
  5523. */
  5524. getStrideSize(): number;
  5525. /**
  5526. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5527. * @param data defines the data to store
  5528. */
  5529. create(data?: Nullable<DataArray>): void;
  5530. /** @hidden */ rebuild(): void;
  5531. /**
  5532. * Update current buffer data
  5533. * @param data defines the data to store
  5534. */
  5535. update(data: DataArray): void;
  5536. /**
  5537. * Updates the data directly.
  5538. * @param data the new data
  5539. * @param offset the new offset
  5540. * @param vertexCount the vertex count (optional)
  5541. * @param useBytes set to true if the offset is in bytes
  5542. */
  5543. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5544. /**
  5545. * Release all resources
  5546. */
  5547. dispose(): void;
  5548. }
  5549. /**
  5550. * Specialized buffer used to store vertex data
  5551. */
  5552. export class VertexBuffer {
  5553. /** @hidden */ buffer: Buffer;
  5554. private _kind;
  5555. private _size;
  5556. private _ownsBuffer;
  5557. private _instanced;
  5558. private _instanceDivisor;
  5559. /**
  5560. * The byte type.
  5561. */
  5562. static readonly BYTE: number;
  5563. /**
  5564. * The unsigned byte type.
  5565. */
  5566. static readonly UNSIGNED_BYTE: number;
  5567. /**
  5568. * The short type.
  5569. */
  5570. static readonly SHORT: number;
  5571. /**
  5572. * The unsigned short type.
  5573. */
  5574. static readonly UNSIGNED_SHORT: number;
  5575. /**
  5576. * The integer type.
  5577. */
  5578. static readonly INT: number;
  5579. /**
  5580. * The unsigned integer type.
  5581. */
  5582. static readonly UNSIGNED_INT: number;
  5583. /**
  5584. * The float type.
  5585. */
  5586. static readonly FLOAT: number;
  5587. /**
  5588. * Gets or sets the instance divisor when in instanced mode
  5589. */
  5590. instanceDivisor: number;
  5591. /**
  5592. * Gets the byte stride.
  5593. */
  5594. readonly byteStride: number;
  5595. /**
  5596. * Gets the byte offset.
  5597. */
  5598. readonly byteOffset: number;
  5599. /**
  5600. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5601. */
  5602. readonly normalized: boolean;
  5603. /**
  5604. * Gets the data type of each component in the array.
  5605. */
  5606. readonly type: number;
  5607. /**
  5608. * Constructor
  5609. * @param engine the engine
  5610. * @param data the data to use for this vertex buffer
  5611. * @param kind the vertex buffer kind
  5612. * @param updatable whether the data is updatable
  5613. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5614. * @param stride the stride (optional)
  5615. * @param instanced whether the buffer is instanced (optional)
  5616. * @param offset the offset of the data (optional)
  5617. * @param size the number of components (optional)
  5618. * @param type the type of the component (optional)
  5619. * @param normalized whether the data contains normalized data (optional)
  5620. * @param useBytes set to true if stride and offset are in bytes (optional)
  5621. */
  5622. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5623. /** @hidden */ rebuild(): void;
  5624. /**
  5625. * Returns the kind of the VertexBuffer (string)
  5626. * @returns a string
  5627. */
  5628. getKind(): string;
  5629. /**
  5630. * Gets a boolean indicating if the VertexBuffer is updatable?
  5631. * @returns true if the buffer is updatable
  5632. */
  5633. isUpdatable(): boolean;
  5634. /**
  5635. * Gets current buffer's data
  5636. * @returns a DataArray or null
  5637. */
  5638. getData(): Nullable<DataArray>;
  5639. /**
  5640. * Gets underlying native buffer
  5641. * @returns underlying native buffer
  5642. */
  5643. getBuffer(): Nullable<DataBuffer>;
  5644. /**
  5645. * Gets the stride in float32 units (i.e. byte stride / 4).
  5646. * May not be an integer if the byte stride is not divisible by 4.
  5647. * DEPRECATED. Use byteStride instead.
  5648. * @returns the stride in float32 units
  5649. */
  5650. getStrideSize(): number;
  5651. /**
  5652. * Returns the offset as a multiple of the type byte length.
  5653. * DEPRECATED. Use byteOffset instead.
  5654. * @returns the offset in bytes
  5655. */
  5656. getOffset(): number;
  5657. /**
  5658. * Returns the number of components per vertex attribute (integer)
  5659. * @returns the size in float
  5660. */
  5661. getSize(): number;
  5662. /**
  5663. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5664. * @returns true if this buffer is instanced
  5665. */
  5666. getIsInstanced(): boolean;
  5667. /**
  5668. * Returns the instancing divisor, zero for non-instanced (integer).
  5669. * @returns a number
  5670. */
  5671. getInstanceDivisor(): number;
  5672. /**
  5673. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5674. * @param data defines the data to store
  5675. */
  5676. create(data?: DataArray): void;
  5677. /**
  5678. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5679. * This function will create a new buffer if the current one is not updatable
  5680. * @param data defines the data to store
  5681. */
  5682. update(data: DataArray): void;
  5683. /**
  5684. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5685. * Returns the directly updated WebGLBuffer.
  5686. * @param data the new data
  5687. * @param offset the new offset
  5688. * @param useBytes set to true if the offset is in bytes
  5689. */
  5690. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5691. /**
  5692. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5693. */
  5694. dispose(): void;
  5695. /**
  5696. * Enumerates each value of this vertex buffer as numbers.
  5697. * @param count the number of values to enumerate
  5698. * @param callback the callback function called for each value
  5699. */
  5700. forEach(count: number, callback: (value: number, index: number) => void): void;
  5701. /**
  5702. * Positions
  5703. */
  5704. static readonly PositionKind: string;
  5705. /**
  5706. * Normals
  5707. */
  5708. static readonly NormalKind: string;
  5709. /**
  5710. * Tangents
  5711. */
  5712. static readonly TangentKind: string;
  5713. /**
  5714. * Texture coordinates
  5715. */
  5716. static readonly UVKind: string;
  5717. /**
  5718. * Texture coordinates 2
  5719. */
  5720. static readonly UV2Kind: string;
  5721. /**
  5722. * Texture coordinates 3
  5723. */
  5724. static readonly UV3Kind: string;
  5725. /**
  5726. * Texture coordinates 4
  5727. */
  5728. static readonly UV4Kind: string;
  5729. /**
  5730. * Texture coordinates 5
  5731. */
  5732. static readonly UV5Kind: string;
  5733. /**
  5734. * Texture coordinates 6
  5735. */
  5736. static readonly UV6Kind: string;
  5737. /**
  5738. * Colors
  5739. */
  5740. static readonly ColorKind: string;
  5741. /**
  5742. * Matrix indices (for bones)
  5743. */
  5744. static readonly MatricesIndicesKind: string;
  5745. /**
  5746. * Matrix weights (for bones)
  5747. */
  5748. static readonly MatricesWeightsKind: string;
  5749. /**
  5750. * Additional matrix indices (for bones)
  5751. */
  5752. static readonly MatricesIndicesExtraKind: string;
  5753. /**
  5754. * Additional matrix weights (for bones)
  5755. */
  5756. static readonly MatricesWeightsExtraKind: string;
  5757. /**
  5758. * Deduces the stride given a kind.
  5759. * @param kind The kind string to deduce
  5760. * @returns The deduced stride
  5761. */
  5762. static DeduceStride(kind: string): number;
  5763. /**
  5764. * Gets the byte length of the given type.
  5765. * @param type the type
  5766. * @returns the number of bytes
  5767. */
  5768. static GetTypeByteLength(type: number): number;
  5769. /**
  5770. * Enumerates each value of the given parameters as numbers.
  5771. * @param data the data to enumerate
  5772. * @param byteOffset the byte offset of the data
  5773. * @param byteStride the byte stride of the data
  5774. * @param componentCount the number of components per element
  5775. * @param componentType the type of the component
  5776. * @param count the total number of components
  5777. * @param normalized whether the data is normalized
  5778. * @param callback the callback function called for each value
  5779. */
  5780. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5781. private static _GetFloatValue;
  5782. }
  5783. }
  5784. declare module BABYLON {
  5785. /**
  5786. * Class representing spherical polynomial coefficients to the 3rd degree
  5787. */
  5788. export class SphericalPolynomial {
  5789. /**
  5790. * The x coefficients of the spherical polynomial
  5791. */
  5792. x: Vector3;
  5793. /**
  5794. * The y coefficients of the spherical polynomial
  5795. */
  5796. y: Vector3;
  5797. /**
  5798. * The z coefficients of the spherical polynomial
  5799. */
  5800. z: Vector3;
  5801. /**
  5802. * The xx coefficients of the spherical polynomial
  5803. */
  5804. xx: Vector3;
  5805. /**
  5806. * The yy coefficients of the spherical polynomial
  5807. */
  5808. yy: Vector3;
  5809. /**
  5810. * The zz coefficients of the spherical polynomial
  5811. */
  5812. zz: Vector3;
  5813. /**
  5814. * The xy coefficients of the spherical polynomial
  5815. */
  5816. xy: Vector3;
  5817. /**
  5818. * The yz coefficients of the spherical polynomial
  5819. */
  5820. yz: Vector3;
  5821. /**
  5822. * The zx coefficients of the spherical polynomial
  5823. */
  5824. zx: Vector3;
  5825. /**
  5826. * Adds an ambient color to the spherical polynomial
  5827. * @param color the color to add
  5828. */
  5829. addAmbient(color: Color3): void;
  5830. /**
  5831. * Scales the spherical polynomial by the given amount
  5832. * @param scale the amount to scale
  5833. */
  5834. scale(scale: number): void;
  5835. /**
  5836. * Gets the spherical polynomial from harmonics
  5837. * @param harmonics the spherical harmonics
  5838. * @returns the spherical polynomial
  5839. */
  5840. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5841. /**
  5842. * Constructs a spherical polynomial from an array.
  5843. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5844. * @returns the spherical polynomial
  5845. */
  5846. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5847. }
  5848. /**
  5849. * Class representing spherical harmonics coefficients to the 3rd degree
  5850. */
  5851. export class SphericalHarmonics {
  5852. /**
  5853. * The l0,0 coefficients of the spherical harmonics
  5854. */
  5855. l00: Vector3;
  5856. /**
  5857. * The l1,-1 coefficients of the spherical harmonics
  5858. */
  5859. l1_1: Vector3;
  5860. /**
  5861. * The l1,0 coefficients of the spherical harmonics
  5862. */
  5863. l10: Vector3;
  5864. /**
  5865. * The l1,1 coefficients of the spherical harmonics
  5866. */
  5867. l11: Vector3;
  5868. /**
  5869. * The l2,-2 coefficients of the spherical harmonics
  5870. */
  5871. l2_2: Vector3;
  5872. /**
  5873. * The l2,-1 coefficients of the spherical harmonics
  5874. */
  5875. l2_1: Vector3;
  5876. /**
  5877. * The l2,0 coefficients of the spherical harmonics
  5878. */
  5879. l20: Vector3;
  5880. /**
  5881. * The l2,1 coefficients of the spherical harmonics
  5882. */
  5883. l21: Vector3;
  5884. /**
  5885. * The l2,2 coefficients of the spherical harmonics
  5886. */
  5887. lL22: Vector3;
  5888. /**
  5889. * Adds a light to the spherical harmonics
  5890. * @param direction the direction of the light
  5891. * @param color the color of the light
  5892. * @param deltaSolidAngle the delta solid angle of the light
  5893. */
  5894. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5895. /**
  5896. * Scales the spherical harmonics by the given amount
  5897. * @param scale the amount to scale
  5898. */
  5899. scale(scale: number): void;
  5900. /**
  5901. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5902. *
  5903. * ```
  5904. * E_lm = A_l * L_lm
  5905. * ```
  5906. *
  5907. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5908. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5909. * the scaling factors are given in equation 9.
  5910. */
  5911. convertIncidentRadianceToIrradiance(): void;
  5912. /**
  5913. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5914. *
  5915. * ```
  5916. * L = (1/pi) * E * rho
  5917. * ```
  5918. *
  5919. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5920. */
  5921. convertIrradianceToLambertianRadiance(): void;
  5922. /**
  5923. * Gets the spherical harmonics from polynomial
  5924. * @param polynomial the spherical polynomial
  5925. * @returns the spherical harmonics
  5926. */
  5927. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5928. /**
  5929. * Constructs a spherical harmonics from an array.
  5930. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5931. * @returns the spherical harmonics
  5932. */
  5933. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5934. }
  5935. }
  5936. declare module BABYLON {
  5937. /**
  5938. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5939. */
  5940. export interface CubeMapInfo {
  5941. /**
  5942. * The pixel array for the front face.
  5943. * This is stored in format, left to right, up to down format.
  5944. */
  5945. front: Nullable<ArrayBufferView>;
  5946. /**
  5947. * The pixel array for the back face.
  5948. * This is stored in format, left to right, up to down format.
  5949. */
  5950. back: Nullable<ArrayBufferView>;
  5951. /**
  5952. * The pixel array for the left face.
  5953. * This is stored in format, left to right, up to down format.
  5954. */
  5955. left: Nullable<ArrayBufferView>;
  5956. /**
  5957. * The pixel array for the right face.
  5958. * This is stored in format, left to right, up to down format.
  5959. */
  5960. right: Nullable<ArrayBufferView>;
  5961. /**
  5962. * The pixel array for the up face.
  5963. * This is stored in format, left to right, up to down format.
  5964. */
  5965. up: Nullable<ArrayBufferView>;
  5966. /**
  5967. * The pixel array for the down face.
  5968. * This is stored in format, left to right, up to down format.
  5969. */
  5970. down: Nullable<ArrayBufferView>;
  5971. /**
  5972. * The size of the cubemap stored.
  5973. *
  5974. * Each faces will be size * size pixels.
  5975. */
  5976. size: number;
  5977. /**
  5978. * The format of the texture.
  5979. *
  5980. * RGBA, RGB.
  5981. */
  5982. format: number;
  5983. /**
  5984. * The type of the texture data.
  5985. *
  5986. * UNSIGNED_INT, FLOAT.
  5987. */
  5988. type: number;
  5989. /**
  5990. * Specifies whether the texture is in gamma space.
  5991. */
  5992. gammaSpace: boolean;
  5993. }
  5994. /**
  5995. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5996. */
  5997. export class PanoramaToCubeMapTools {
  5998. private static FACE_FRONT;
  5999. private static FACE_BACK;
  6000. private static FACE_RIGHT;
  6001. private static FACE_LEFT;
  6002. private static FACE_DOWN;
  6003. private static FACE_UP;
  6004. /**
  6005. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6006. *
  6007. * @param float32Array The source data.
  6008. * @param inputWidth The width of the input panorama.
  6009. * @param inputHeight The height of the input panorama.
  6010. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6011. * @return The cubemap data
  6012. */
  6013. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6014. private static CreateCubemapTexture;
  6015. private static CalcProjectionSpherical;
  6016. }
  6017. }
  6018. declare module BABYLON {
  6019. /**
  6020. * Helper class dealing with the extraction of spherical polynomial dataArray
  6021. * from a cube map.
  6022. */
  6023. export class CubeMapToSphericalPolynomialTools {
  6024. private static FileFaces;
  6025. /**
  6026. * Converts a texture to the according Spherical Polynomial data.
  6027. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6028. *
  6029. * @param texture The texture to extract the information from.
  6030. * @return The Spherical Polynomial data.
  6031. */
  6032. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6033. /**
  6034. * Converts a cubemap to the according Spherical Polynomial data.
  6035. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6036. *
  6037. * @param cubeInfo The Cube map to extract the information from.
  6038. * @return The Spherical Polynomial data.
  6039. */
  6040. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6041. }
  6042. }
  6043. declare module BABYLON {
  6044. /**
  6045. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6046. * during the life time of the application.
  6047. */
  6048. export class EngineStore {
  6049. /** Gets the list of created engines */
  6050. static Instances: Engine[];
  6051. /**
  6052. * Gets the latest created engine
  6053. */
  6054. static readonly LastCreatedEngine: Nullable<Engine>;
  6055. /**
  6056. * Gets the latest created scene
  6057. */
  6058. static readonly LastCreatedScene: Nullable<Scene>;
  6059. }
  6060. }
  6061. declare module BABYLON {
  6062. /**
  6063. * Define options used to create a render target texture
  6064. */
  6065. export class RenderTargetCreationOptions {
  6066. /**
  6067. * Specifies is mipmaps must be generated
  6068. */
  6069. generateMipMaps?: boolean;
  6070. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6071. generateDepthBuffer?: boolean;
  6072. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6073. generateStencilBuffer?: boolean;
  6074. /** Defines texture type (int by default) */
  6075. type?: number;
  6076. /** Defines sampling mode (trilinear by default) */
  6077. samplingMode?: number;
  6078. /** Defines format (RGBA by default) */
  6079. format?: number;
  6080. }
  6081. }
  6082. declare module BABYLON {
  6083. /**
  6084. * @hidden
  6085. **/
  6086. export class _AlphaState {
  6087. private _isAlphaBlendDirty;
  6088. private _isBlendFunctionParametersDirty;
  6089. private _isBlendEquationParametersDirty;
  6090. private _isBlendConstantsDirty;
  6091. private _alphaBlend;
  6092. private _blendFunctionParameters;
  6093. private _blendEquationParameters;
  6094. private _blendConstants;
  6095. /**
  6096. * Initializes the state.
  6097. */
  6098. constructor();
  6099. readonly isDirty: boolean;
  6100. alphaBlend: boolean;
  6101. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6102. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6103. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6104. reset(): void;
  6105. apply(gl: WebGLRenderingContext): void;
  6106. }
  6107. }
  6108. declare module BABYLON {
  6109. /**
  6110. * @hidden
  6111. **/
  6112. export class _DepthCullingState {
  6113. private _isDepthTestDirty;
  6114. private _isDepthMaskDirty;
  6115. private _isDepthFuncDirty;
  6116. private _isCullFaceDirty;
  6117. private _isCullDirty;
  6118. private _isZOffsetDirty;
  6119. private _isFrontFaceDirty;
  6120. private _depthTest;
  6121. private _depthMask;
  6122. private _depthFunc;
  6123. private _cull;
  6124. private _cullFace;
  6125. private _zOffset;
  6126. private _frontFace;
  6127. /**
  6128. * Initializes the state.
  6129. */
  6130. constructor();
  6131. readonly isDirty: boolean;
  6132. zOffset: number;
  6133. cullFace: Nullable<number>;
  6134. cull: Nullable<boolean>;
  6135. depthFunc: Nullable<number>;
  6136. depthMask: boolean;
  6137. depthTest: boolean;
  6138. frontFace: Nullable<number>;
  6139. reset(): void;
  6140. apply(gl: WebGLRenderingContext): void;
  6141. }
  6142. }
  6143. declare module BABYLON {
  6144. /**
  6145. * @hidden
  6146. **/
  6147. export class _StencilState {
  6148. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6149. static readonly ALWAYS: number;
  6150. /** Passed to stencilOperation to specify that stencil value must be kept */
  6151. static readonly KEEP: number;
  6152. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6153. static readonly REPLACE: number;
  6154. private _isStencilTestDirty;
  6155. private _isStencilMaskDirty;
  6156. private _isStencilFuncDirty;
  6157. private _isStencilOpDirty;
  6158. private _stencilTest;
  6159. private _stencilMask;
  6160. private _stencilFunc;
  6161. private _stencilFuncRef;
  6162. private _stencilFuncMask;
  6163. private _stencilOpStencilFail;
  6164. private _stencilOpDepthFail;
  6165. private _stencilOpStencilDepthPass;
  6166. readonly isDirty: boolean;
  6167. stencilFunc: number;
  6168. stencilFuncRef: number;
  6169. stencilFuncMask: number;
  6170. stencilOpStencilFail: number;
  6171. stencilOpDepthFail: number;
  6172. stencilOpStencilDepthPass: number;
  6173. stencilMask: number;
  6174. stencilTest: boolean;
  6175. constructor();
  6176. reset(): void;
  6177. apply(gl: WebGLRenderingContext): void;
  6178. }
  6179. }
  6180. declare module BABYLON {
  6181. /**
  6182. * @hidden
  6183. **/
  6184. export class _TimeToken { startTimeQuery: Nullable<WebGLQuery>; endTimeQuery: Nullable<WebGLQuery>; timeElapsedQuery: Nullable<WebGLQuery>; timeElapsedQueryEnded: boolean;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. /**
  6189. * Class used to store data associated with WebGL texture data for the engine
  6190. * This class should not be used directly
  6191. */
  6192. export class InternalTexture {
  6193. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6194. /**
  6195. * The source of the texture data is unknown
  6196. */
  6197. static DATASOURCE_UNKNOWN: number;
  6198. /**
  6199. * Texture data comes from an URL
  6200. */
  6201. static DATASOURCE_URL: number;
  6202. /**
  6203. * Texture data is only used for temporary storage
  6204. */
  6205. static DATASOURCE_TEMP: number;
  6206. /**
  6207. * Texture data comes from raw data (ArrayBuffer)
  6208. */
  6209. static DATASOURCE_RAW: number;
  6210. /**
  6211. * Texture content is dynamic (video or dynamic texture)
  6212. */
  6213. static DATASOURCE_DYNAMIC: number;
  6214. /**
  6215. * Texture content is generated by rendering to it
  6216. */
  6217. static DATASOURCE_RENDERTARGET: number;
  6218. /**
  6219. * Texture content is part of a multi render target process
  6220. */
  6221. static DATASOURCE_MULTIRENDERTARGET: number;
  6222. /**
  6223. * Texture data comes from a cube data file
  6224. */
  6225. static DATASOURCE_CUBE: number;
  6226. /**
  6227. * Texture data comes from a raw cube data
  6228. */
  6229. static DATASOURCE_CUBERAW: number;
  6230. /**
  6231. * Texture data come from a prefiltered cube data file
  6232. */
  6233. static DATASOURCE_CUBEPREFILTERED: number;
  6234. /**
  6235. * Texture content is raw 3D data
  6236. */
  6237. static DATASOURCE_RAW3D: number;
  6238. /**
  6239. * Texture content is a depth texture
  6240. */
  6241. static DATASOURCE_DEPTHTEXTURE: number;
  6242. /**
  6243. * Texture data comes from a raw cube data encoded with RGBD
  6244. */
  6245. static DATASOURCE_CUBERAW_RGBD: number;
  6246. /**
  6247. * Defines if the texture is ready
  6248. */
  6249. isReady: boolean;
  6250. /**
  6251. * Defines if the texture is a cube texture
  6252. */
  6253. isCube: boolean;
  6254. /**
  6255. * Defines if the texture contains 3D data
  6256. */
  6257. is3D: boolean;
  6258. /**
  6259. * Defines if the texture contains multiview data
  6260. */
  6261. isMultiview: boolean;
  6262. /**
  6263. * Gets the URL used to load this texture
  6264. */
  6265. url: string;
  6266. /**
  6267. * Gets the sampling mode of the texture
  6268. */
  6269. samplingMode: number;
  6270. /**
  6271. * Gets a boolean indicating if the texture needs mipmaps generation
  6272. */
  6273. generateMipMaps: boolean;
  6274. /**
  6275. * Gets the number of samples used by the texture (WebGL2+ only)
  6276. */
  6277. samples: number;
  6278. /**
  6279. * Gets the type of the texture (int, float...)
  6280. */
  6281. type: number;
  6282. /**
  6283. * Gets the format of the texture (RGB, RGBA...)
  6284. */
  6285. format: number;
  6286. /**
  6287. * Observable called when the texture is loaded
  6288. */
  6289. onLoadedObservable: Observable<InternalTexture>;
  6290. /**
  6291. * Gets the width of the texture
  6292. */
  6293. width: number;
  6294. /**
  6295. * Gets the height of the texture
  6296. */
  6297. height: number;
  6298. /**
  6299. * Gets the depth of the texture
  6300. */
  6301. depth: number;
  6302. /**
  6303. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6304. */
  6305. baseWidth: number;
  6306. /**
  6307. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6308. */
  6309. baseHeight: number;
  6310. /**
  6311. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6312. */
  6313. baseDepth: number;
  6314. /**
  6315. * Gets a boolean indicating if the texture is inverted on Y axis
  6316. */
  6317. invertY: boolean;
  6318. /** @hidden */ invertVScale: boolean;
  6319. /** @hidden */ associatedChannel: number;
  6320. /** @hidden */ dataSource: number;
  6321. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6322. /** @hidden */ bufferView: Nullable<ArrayBufferView>;
  6323. /** @hidden */ bufferViewArray: Nullable<ArrayBufferView[]>;
  6324. /** @hidden */ bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6325. /** @hidden */ size: number;
  6326. /** @hidden */ extension: string;
  6327. /** @hidden */ files: Nullable<string[]>;
  6328. /** @hidden */ workingCanvas: Nullable<HTMLCanvasElement>;
  6329. /** @hidden */ workingContext: Nullable<CanvasRenderingContext2D>;
  6330. /** @hidden */ framebuffer: Nullable<WebGLFramebuffer>;
  6331. /** @hidden */ depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6332. /** @hidden */ MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6333. /** @hidden */ MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6334. /** @hidden */ attachments: Nullable<number[]>;
  6335. /** @hidden */ cachedCoordinatesMode: Nullable<number>;
  6336. /** @hidden */ cachedWrapU: Nullable<number>;
  6337. /** @hidden */ cachedWrapV: Nullable<number>;
  6338. /** @hidden */ cachedWrapR: Nullable<number>;
  6339. /** @hidden */ cachedAnisotropicFilteringLevel: Nullable<number>;
  6340. /** @hidden */ isDisabled: boolean;
  6341. /** @hidden */ compression: Nullable<string>;
  6342. /** @hidden */ generateStencilBuffer: boolean;
  6343. /** @hidden */ generateDepthBuffer: boolean;
  6344. /** @hidden */ comparisonFunction: number;
  6345. /** @hidden */ sphericalPolynomial: Nullable<SphericalPolynomial>;
  6346. /** @hidden */ lodGenerationScale: number;
  6347. /** @hidden */ lodGenerationOffset: number;
  6348. /** @hidden */ colorTextureArray: Nullable<WebGLTexture>;
  6349. /** @hidden */ depthStencilTextureArray: Nullable<WebGLTexture>;
  6350. /** @hidden */ lodTextureHigh: Nullable<BaseTexture>;
  6351. /** @hidden */ lodTextureMid: Nullable<BaseTexture>;
  6352. /** @hidden */ lodTextureLow: Nullable<BaseTexture>;
  6353. /** @hidden */ isRGBD: boolean;
  6354. /** @hidden */ webGLTexture: Nullable<WebGLTexture>;
  6355. /** @hidden */ references: number;
  6356. private _engine;
  6357. /**
  6358. * Gets the Engine the texture belongs to.
  6359. * @returns The babylon engine
  6360. */
  6361. getEngine(): Engine;
  6362. /**
  6363. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6364. */
  6365. readonly dataSource: number;
  6366. /**
  6367. * Creates a new InternalTexture
  6368. * @param engine defines the engine to use
  6369. * @param dataSource defines the type of data that will be used
  6370. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6371. */
  6372. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6373. /**
  6374. * Increments the number of references (ie. the number of Texture that point to it)
  6375. */
  6376. incrementReferences(): void;
  6377. /**
  6378. * Change the size of the texture (not the size of the content)
  6379. * @param width defines the new width
  6380. * @param height defines the new height
  6381. * @param depth defines the new depth (1 by default)
  6382. */
  6383. updateSize(width: int, height: int, depth?: int): void;
  6384. /** @hidden */ rebuild(): void;
  6385. /** @hidden */ swapAndDie(target: InternalTexture): void;
  6386. /**
  6387. * Dispose the current allocated resources
  6388. */
  6389. dispose(): void;
  6390. }
  6391. }
  6392. declare module BABYLON {
  6393. /**
  6394. * This represents the main contract an easing function should follow.
  6395. * Easing functions are used throughout the animation system.
  6396. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6397. */
  6398. export interface IEasingFunction {
  6399. /**
  6400. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6401. * of the easing function.
  6402. * The link below provides some of the most common examples of easing functions.
  6403. * @see https://easings.net/
  6404. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6405. * @returns the corresponding value on the curve defined by the easing function
  6406. */
  6407. ease(gradient: number): number;
  6408. }
  6409. /**
  6410. * Base class used for every default easing function.
  6411. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6412. */
  6413. export class EasingFunction implements IEasingFunction {
  6414. /**
  6415. * Interpolation follows the mathematical formula associated with the easing function.
  6416. */
  6417. static readonly EASINGMODE_EASEIN: number;
  6418. /**
  6419. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6420. */
  6421. static readonly EASINGMODE_EASEOUT: number;
  6422. /**
  6423. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6424. */
  6425. static readonly EASINGMODE_EASEINOUT: number;
  6426. private _easingMode;
  6427. /**
  6428. * Sets the easing mode of the current function.
  6429. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6430. */
  6431. setEasingMode(easingMode: number): void;
  6432. /**
  6433. * Gets the current easing mode.
  6434. * @returns the easing mode
  6435. */
  6436. getEasingMode(): number;
  6437. /**
  6438. * @hidden
  6439. */
  6440. easeInCore(gradient: number): number;
  6441. /**
  6442. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6443. * of the easing function.
  6444. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6445. * @returns the corresponding value on the curve defined by the easing function
  6446. */
  6447. ease(gradient: number): number;
  6448. }
  6449. /**
  6450. * Easing function with a circle shape (see link below).
  6451. * @see https://easings.net/#easeInCirc
  6452. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6453. */
  6454. export class CircleEase extends EasingFunction implements IEasingFunction {
  6455. /** @hidden */
  6456. easeInCore(gradient: number): number;
  6457. }
  6458. /**
  6459. * Easing function with a ease back shape (see link below).
  6460. * @see https://easings.net/#easeInBack
  6461. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6462. */
  6463. export class BackEase extends EasingFunction implements IEasingFunction {
  6464. /** Defines the amplitude of the function */
  6465. amplitude: number;
  6466. /**
  6467. * Instantiates a back ease easing
  6468. * @see https://easings.net/#easeInBack
  6469. * @param amplitude Defines the amplitude of the function
  6470. */
  6471. constructor(
  6472. /** Defines the amplitude of the function */
  6473. amplitude?: number);
  6474. /** @hidden */
  6475. easeInCore(gradient: number): number;
  6476. }
  6477. /**
  6478. * Easing function with a bouncing shape (see link below).
  6479. * @see https://easings.net/#easeInBounce
  6480. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6481. */
  6482. export class BounceEase extends EasingFunction implements IEasingFunction {
  6483. /** Defines the number of bounces */
  6484. bounces: number;
  6485. /** Defines the amplitude of the bounce */
  6486. bounciness: number;
  6487. /**
  6488. * Instantiates a bounce easing
  6489. * @see https://easings.net/#easeInBounce
  6490. * @param bounces Defines the number of bounces
  6491. * @param bounciness Defines the amplitude of the bounce
  6492. */
  6493. constructor(
  6494. /** Defines the number of bounces */
  6495. bounces?: number,
  6496. /** Defines the amplitude of the bounce */
  6497. bounciness?: number);
  6498. /** @hidden */
  6499. easeInCore(gradient: number): number;
  6500. }
  6501. /**
  6502. * Easing function with a power of 3 shape (see link below).
  6503. * @see https://easings.net/#easeInCubic
  6504. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6505. */
  6506. export class CubicEase extends EasingFunction implements IEasingFunction {
  6507. /** @hidden */
  6508. easeInCore(gradient: number): number;
  6509. }
  6510. /**
  6511. * Easing function with an elastic shape (see link below).
  6512. * @see https://easings.net/#easeInElastic
  6513. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6514. */
  6515. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6516. /** Defines the number of oscillations*/
  6517. oscillations: number;
  6518. /** Defines the amplitude of the oscillations*/
  6519. springiness: number;
  6520. /**
  6521. * Instantiates an elastic easing function
  6522. * @see https://easings.net/#easeInElastic
  6523. * @param oscillations Defines the number of oscillations
  6524. * @param springiness Defines the amplitude of the oscillations
  6525. */
  6526. constructor(
  6527. /** Defines the number of oscillations*/
  6528. oscillations?: number,
  6529. /** Defines the amplitude of the oscillations*/
  6530. springiness?: number);
  6531. /** @hidden */
  6532. easeInCore(gradient: number): number;
  6533. }
  6534. /**
  6535. * Easing function with an exponential shape (see link below).
  6536. * @see https://easings.net/#easeInExpo
  6537. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6538. */
  6539. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6540. /** Defines the exponent of the function */
  6541. exponent: number;
  6542. /**
  6543. * Instantiates an exponential easing function
  6544. * @see https://easings.net/#easeInExpo
  6545. * @param exponent Defines the exponent of the function
  6546. */
  6547. constructor(
  6548. /** Defines the exponent of the function */
  6549. exponent?: number);
  6550. /** @hidden */
  6551. easeInCore(gradient: number): number;
  6552. }
  6553. /**
  6554. * Easing function with a power shape (see link below).
  6555. * @see https://easings.net/#easeInQuad
  6556. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6557. */
  6558. export class PowerEase extends EasingFunction implements IEasingFunction {
  6559. /** Defines the power of the function */
  6560. power: number;
  6561. /**
  6562. * Instantiates an power base easing function
  6563. * @see https://easings.net/#easeInQuad
  6564. * @param power Defines the power of the function
  6565. */
  6566. constructor(
  6567. /** Defines the power of the function */
  6568. power?: number);
  6569. /** @hidden */
  6570. easeInCore(gradient: number): number;
  6571. }
  6572. /**
  6573. * Easing function with a power of 2 shape (see link below).
  6574. * @see https://easings.net/#easeInQuad
  6575. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6576. */
  6577. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6578. /** @hidden */
  6579. easeInCore(gradient: number): number;
  6580. }
  6581. /**
  6582. * Easing function with a power of 4 shape (see link below).
  6583. * @see https://easings.net/#easeInQuart
  6584. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6585. */
  6586. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6587. /** @hidden */
  6588. easeInCore(gradient: number): number;
  6589. }
  6590. /**
  6591. * Easing function with a power of 5 shape (see link below).
  6592. * @see https://easings.net/#easeInQuint
  6593. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6594. */
  6595. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6596. /** @hidden */
  6597. easeInCore(gradient: number): number;
  6598. }
  6599. /**
  6600. * Easing function with a sin shape (see link below).
  6601. * @see https://easings.net/#easeInSine
  6602. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6603. */
  6604. export class SineEase extends EasingFunction implements IEasingFunction {
  6605. /** @hidden */
  6606. easeInCore(gradient: number): number;
  6607. }
  6608. /**
  6609. * Easing function with a bezier shape (see link below).
  6610. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6611. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6612. */
  6613. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6614. /** Defines the x component of the start tangent in the bezier curve */
  6615. x1: number;
  6616. /** Defines the y component of the start tangent in the bezier curve */
  6617. y1: number;
  6618. /** Defines the x component of the end tangent in the bezier curve */
  6619. x2: number;
  6620. /** Defines the y component of the end tangent in the bezier curve */
  6621. y2: number;
  6622. /**
  6623. * Instantiates a bezier function
  6624. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6625. * @param x1 Defines the x component of the start tangent in the bezier curve
  6626. * @param y1 Defines the y component of the start tangent in the bezier curve
  6627. * @param x2 Defines the x component of the end tangent in the bezier curve
  6628. * @param y2 Defines the y component of the end tangent in the bezier curve
  6629. */
  6630. constructor(
  6631. /** Defines the x component of the start tangent in the bezier curve */
  6632. x1?: number,
  6633. /** Defines the y component of the start tangent in the bezier curve */
  6634. y1?: number,
  6635. /** Defines the x component of the end tangent in the bezier curve */
  6636. x2?: number,
  6637. /** Defines the y component of the end tangent in the bezier curve */
  6638. y2?: number);
  6639. /** @hidden */
  6640. easeInCore(gradient: number): number;
  6641. }
  6642. }
  6643. declare module BABYLON {
  6644. /**
  6645. * Defines an interface which represents an animation key frame
  6646. */
  6647. export interface IAnimationKey {
  6648. /**
  6649. * Frame of the key frame
  6650. */
  6651. frame: number;
  6652. /**
  6653. * Value at the specifies key frame
  6654. */
  6655. value: any;
  6656. /**
  6657. * The input tangent for the cubic hermite spline
  6658. */
  6659. inTangent?: any;
  6660. /**
  6661. * The output tangent for the cubic hermite spline
  6662. */
  6663. outTangent?: any;
  6664. /**
  6665. * The animation interpolation type
  6666. */
  6667. interpolation?: AnimationKeyInterpolation;
  6668. }
  6669. /**
  6670. * Enum for the animation key frame interpolation type
  6671. */
  6672. export enum AnimationKeyInterpolation {
  6673. /**
  6674. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6675. */
  6676. STEP = 1
  6677. }
  6678. }
  6679. declare module BABYLON {
  6680. /**
  6681. * Represents the range of an animation
  6682. */
  6683. export class AnimationRange {
  6684. /**The name of the animation range**/
  6685. name: string;
  6686. /**The starting frame of the animation */
  6687. from: number;
  6688. /**The ending frame of the animation*/
  6689. to: number;
  6690. /**
  6691. * Initializes the range of an animation
  6692. * @param name The name of the animation range
  6693. * @param from The starting frame of the animation
  6694. * @param to The ending frame of the animation
  6695. */
  6696. constructor(
  6697. /**The name of the animation range**/
  6698. name: string,
  6699. /**The starting frame of the animation */
  6700. from: number,
  6701. /**The ending frame of the animation*/
  6702. to: number);
  6703. /**
  6704. * Makes a copy of the animation range
  6705. * @returns A copy of the animation range
  6706. */
  6707. clone(): AnimationRange;
  6708. }
  6709. }
  6710. declare module BABYLON {
  6711. /**
  6712. * Composed of a frame, and an action function
  6713. */
  6714. export class AnimationEvent {
  6715. /** The frame for which the event is triggered **/
  6716. frame: number;
  6717. /** The event to perform when triggered **/
  6718. action: (currentFrame: number) => void;
  6719. /** Specifies if the event should be triggered only once**/
  6720. onlyOnce?: boolean | undefined;
  6721. /**
  6722. * Specifies if the animation event is done
  6723. */
  6724. isDone: boolean;
  6725. /**
  6726. * Initializes the animation event
  6727. * @param frame The frame for which the event is triggered
  6728. * @param action The event to perform when triggered
  6729. * @param onlyOnce Specifies if the event should be triggered only once
  6730. */
  6731. constructor(
  6732. /** The frame for which the event is triggered **/
  6733. frame: number,
  6734. /** The event to perform when triggered **/
  6735. action: (currentFrame: number) => void,
  6736. /** Specifies if the event should be triggered only once**/
  6737. onlyOnce?: boolean | undefined);
  6738. /** @hidden */ clone(): AnimationEvent;
  6739. }
  6740. }
  6741. declare module BABYLON {
  6742. /**
  6743. * Interface used to define a behavior
  6744. */
  6745. export interface Behavior<T> {
  6746. /** gets or sets behavior's name */
  6747. name: string;
  6748. /**
  6749. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6750. */
  6751. init(): void;
  6752. /**
  6753. * Called when the behavior is attached to a target
  6754. * @param target defines the target where the behavior is attached to
  6755. */
  6756. attach(target: T): void;
  6757. /**
  6758. * Called when the behavior is detached from its target
  6759. */
  6760. detach(): void;
  6761. }
  6762. /**
  6763. * Interface implemented by classes supporting behaviors
  6764. */
  6765. export interface IBehaviorAware<T> {
  6766. /**
  6767. * Attach a behavior
  6768. * @param behavior defines the behavior to attach
  6769. * @returns the current host
  6770. */
  6771. addBehavior(behavior: Behavior<T>): T;
  6772. /**
  6773. * Remove a behavior from the current object
  6774. * @param behavior defines the behavior to detach
  6775. * @returns the current host
  6776. */
  6777. removeBehavior(behavior: Behavior<T>): T;
  6778. /**
  6779. * Gets a behavior using its name to search
  6780. * @param name defines the name to search
  6781. * @returns the behavior or null if not found
  6782. */
  6783. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6784. }
  6785. }
  6786. declare module BABYLON {
  6787. /**
  6788. * @hidden
  6789. */
  6790. export class IntersectionInfo {
  6791. bu: Nullable<number>;
  6792. bv: Nullable<number>;
  6793. distance: number;
  6794. faceId: number;
  6795. subMeshId: number;
  6796. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6797. }
  6798. }
  6799. declare module BABYLON {
  6800. /**
  6801. * Class used to store bounding sphere information
  6802. */
  6803. export class BoundingSphere {
  6804. /**
  6805. * Gets the center of the bounding sphere in local space
  6806. */
  6807. readonly center: Vector3;
  6808. /**
  6809. * Radius of the bounding sphere in local space
  6810. */
  6811. radius: number;
  6812. /**
  6813. * Gets the center of the bounding sphere in world space
  6814. */
  6815. readonly centerWorld: Vector3;
  6816. /**
  6817. * Radius of the bounding sphere in world space
  6818. */
  6819. radiusWorld: number;
  6820. /**
  6821. * Gets the minimum vector in local space
  6822. */
  6823. readonly minimum: Vector3;
  6824. /**
  6825. * Gets the maximum vector in local space
  6826. */
  6827. readonly maximum: Vector3;
  6828. private _worldMatrix;
  6829. private static readonly TmpVector3;
  6830. /**
  6831. * Creates a new bounding sphere
  6832. * @param min defines the minimum vector (in local space)
  6833. * @param max defines the maximum vector (in local space)
  6834. * @param worldMatrix defines the new world matrix
  6835. */
  6836. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6837. /**
  6838. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6839. * @param min defines the new minimum vector (in local space)
  6840. * @param max defines the new maximum vector (in local space)
  6841. * @param worldMatrix defines the new world matrix
  6842. */
  6843. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6844. /**
  6845. * Scale the current bounding sphere by applying a scale factor
  6846. * @param factor defines the scale factor to apply
  6847. * @returns the current bounding box
  6848. */
  6849. scale(factor: number): BoundingSphere;
  6850. /**
  6851. * Gets the world matrix of the bounding box
  6852. * @returns a matrix
  6853. */
  6854. getWorldMatrix(): DeepImmutable<Matrix>;
  6855. /** @hidden */ update(worldMatrix: DeepImmutable<Matrix>): void;
  6856. /**
  6857. * Tests if the bounding sphere is intersecting the frustum planes
  6858. * @param frustumPlanes defines the frustum planes to test
  6859. * @returns true if there is an intersection
  6860. */
  6861. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6862. /**
  6863. * Tests if the bounding sphere center is in between the frustum planes.
  6864. * Used for optimistic fast inclusion.
  6865. * @param frustumPlanes defines the frustum planes to test
  6866. * @returns true if the sphere center is in between the frustum planes
  6867. */
  6868. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6869. /**
  6870. * Tests if a point is inside the bounding sphere
  6871. * @param point defines the point to test
  6872. * @returns true if the point is inside the bounding sphere
  6873. */
  6874. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6875. /**
  6876. * Checks if two sphere intersct
  6877. * @param sphere0 sphere 0
  6878. * @param sphere1 sphere 1
  6879. * @returns true if the speres intersect
  6880. */
  6881. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6882. }
  6883. }
  6884. declare module BABYLON {
  6885. /**
  6886. * Class used to store bounding box information
  6887. */
  6888. export class BoundingBox implements ICullable {
  6889. /**
  6890. * Gets the 8 vectors representing the bounding box in local space
  6891. */
  6892. readonly vectors: Vector3[];
  6893. /**
  6894. * Gets the center of the bounding box in local space
  6895. */
  6896. readonly center: Vector3;
  6897. /**
  6898. * Gets the center of the bounding box in world space
  6899. */
  6900. readonly centerWorld: Vector3;
  6901. /**
  6902. * Gets the extend size in local space
  6903. */
  6904. readonly extendSize: Vector3;
  6905. /**
  6906. * Gets the extend size in world space
  6907. */
  6908. readonly extendSizeWorld: Vector3;
  6909. /**
  6910. * Gets the OBB (object bounding box) directions
  6911. */
  6912. readonly directions: Vector3[];
  6913. /**
  6914. * Gets the 8 vectors representing the bounding box in world space
  6915. */
  6916. readonly vectorsWorld: Vector3[];
  6917. /**
  6918. * Gets the minimum vector in world space
  6919. */
  6920. readonly minimumWorld: Vector3;
  6921. /**
  6922. * Gets the maximum vector in world space
  6923. */
  6924. readonly maximumWorld: Vector3;
  6925. /**
  6926. * Gets the minimum vector in local space
  6927. */
  6928. readonly minimum: Vector3;
  6929. /**
  6930. * Gets the maximum vector in local space
  6931. */
  6932. readonly maximum: Vector3;
  6933. private _worldMatrix;
  6934. private static readonly TmpVector3;
  6935. /**
  6936. * @hidden
  6937. */ tag: number;
  6938. /**
  6939. * Creates a new bounding box
  6940. * @param min defines the minimum vector (in local space)
  6941. * @param max defines the maximum vector (in local space)
  6942. * @param worldMatrix defines the new world matrix
  6943. */
  6944. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6945. /**
  6946. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6947. * @param min defines the new minimum vector (in local space)
  6948. * @param max defines the new maximum vector (in local space)
  6949. * @param worldMatrix defines the new world matrix
  6950. */
  6951. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6952. /**
  6953. * Scale the current bounding box by applying a scale factor
  6954. * @param factor defines the scale factor to apply
  6955. * @returns the current bounding box
  6956. */
  6957. scale(factor: number): BoundingBox;
  6958. /**
  6959. * Gets the world matrix of the bounding box
  6960. * @returns a matrix
  6961. */
  6962. getWorldMatrix(): DeepImmutable<Matrix>;
  6963. /** @hidden */ update(world: DeepImmutable<Matrix>): void;
  6964. /**
  6965. * Tests if the bounding box is intersecting the frustum planes
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if the bounding box is entirely inside the frustum planes
  6972. * @param frustumPlanes defines the frustum planes to test
  6973. * @returns true if there is an inclusion
  6974. */
  6975. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6976. /**
  6977. * Tests if a point is inside the bounding box
  6978. * @param point defines the point to test
  6979. * @returns true if the point is inside the bounding box
  6980. */
  6981. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6982. /**
  6983. * Tests if the bounding box intersects with a bounding sphere
  6984. * @param sphere defines the sphere to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6988. /**
  6989. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6990. * @param min defines the min vector to use
  6991. * @param max defines the max vector to use
  6992. * @returns true if there is an intersection
  6993. */
  6994. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6995. /**
  6996. * Tests if two bounding boxes are intersections
  6997. * @param box0 defines the first box to test
  6998. * @param box1 defines the second box to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7002. /**
  7003. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7004. * @param minPoint defines the minimum vector of the bounding box
  7005. * @param maxPoint defines the maximum vector of the bounding box
  7006. * @param sphereCenter defines the sphere center
  7007. * @param sphereRadius defines the sphere radius
  7008. * @returns true if there is an intersection
  7009. */
  7010. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7011. /**
  7012. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7013. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7014. * @param frustumPlanes defines the frustum planes to test
  7015. * @return true if there is an inclusion
  7016. */
  7017. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7018. /**
  7019. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7020. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @return true if there is an intersection
  7023. */
  7024. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. }
  7026. }
  7027. declare module BABYLON {
  7028. /** @hidden */
  7029. export class Collider {
  7030. /** Define if a collision was found */
  7031. collisionFound: boolean;
  7032. /**
  7033. * Define last intersection point in local space
  7034. */
  7035. intersectionPoint: Vector3;
  7036. /**
  7037. * Define last collided mesh
  7038. */
  7039. collidedMesh: Nullable<AbstractMesh>;
  7040. private _collisionPoint;
  7041. private _planeIntersectionPoint;
  7042. private _tempVector;
  7043. private _tempVector2;
  7044. private _tempVector3;
  7045. private _tempVector4;
  7046. private _edge;
  7047. private _baseToVertex;
  7048. private _destinationPoint;
  7049. private _slidePlaneNormal;
  7050. private _displacementVector;
  7051. /** @hidden */ radius: Vector3;
  7052. /** @hidden */ retry: number;
  7053. private _velocity;
  7054. private _basePoint;
  7055. private _epsilon;
  7056. /** @hidden */ velocityWorldLength: number;
  7057. /** @hidden */ basePointWorld: Vector3;
  7058. private _velocityWorld;
  7059. private _normalizedVelocity;
  7060. /** @hidden */ initialVelocity: Vector3;
  7061. /** @hidden */ initialPosition: Vector3;
  7062. private _nearestDistance;
  7063. private _collisionMask;
  7064. collisionMask: number;
  7065. /**
  7066. * Gets the plane normal used to compute the sliding response (in local space)
  7067. */
  7068. readonly slidePlaneNormal: Vector3;
  7069. /** @hidden */ initialize(source: Vector3, dir: Vector3, e: number): void;
  7070. /** @hidden */ checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7071. /** @hidden */ canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7072. /** @hidden */ testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7073. /** @hidden */ collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7074. /** @hidden */ getResponse(pos: Vector3, vel: Vector3): void;
  7075. }
  7076. }
  7077. declare module BABYLON {
  7078. /**
  7079. * Interface for cullable objects
  7080. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7081. */
  7082. export interface ICullable {
  7083. /**
  7084. * Checks if the object or part of the object is in the frustum
  7085. * @param frustumPlanes Camera near/planes
  7086. * @returns true if the object is in frustum otherwise false
  7087. */
  7088. isInFrustum(frustumPlanes: Plane[]): boolean;
  7089. /**
  7090. * Checks if a cullable object (mesh...) is in the camera frustum
  7091. * Unlike isInFrustum this cheks the full bounding box
  7092. * @param frustumPlanes Camera near/planes
  7093. * @returns true if the object is in frustum otherwise false
  7094. */
  7095. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7096. }
  7097. /**
  7098. * Info for a bounding data of a mesh
  7099. */
  7100. export class BoundingInfo implements ICullable {
  7101. /**
  7102. * Bounding box for the mesh
  7103. */
  7104. readonly boundingBox: BoundingBox;
  7105. /**
  7106. * Bounding sphere for the mesh
  7107. */
  7108. readonly boundingSphere: BoundingSphere;
  7109. private _isLocked;
  7110. private static readonly TmpVector3;
  7111. /**
  7112. * Constructs bounding info
  7113. * @param minimum min vector of the bounding box/sphere
  7114. * @param maximum max vector of the bounding box/sphere
  7115. * @param worldMatrix defines the new world matrix
  7116. */
  7117. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7118. /**
  7119. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7120. * @param min defines the new minimum vector (in local space)
  7121. * @param max defines the new maximum vector (in local space)
  7122. * @param worldMatrix defines the new world matrix
  7123. */
  7124. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7125. /**
  7126. * min vector of the bounding box/sphere
  7127. */
  7128. readonly minimum: Vector3;
  7129. /**
  7130. * max vector of the bounding box/sphere
  7131. */
  7132. readonly maximum: Vector3;
  7133. /**
  7134. * If the info is locked and won't be updated to avoid perf overhead
  7135. */
  7136. isLocked: boolean;
  7137. /**
  7138. * Updates the bounding sphere and box
  7139. * @param world world matrix to be used to update
  7140. */
  7141. update(world: DeepImmutable<Matrix>): void;
  7142. /**
  7143. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7144. * @param center New center of the bounding info
  7145. * @param extend New extend of the bounding info
  7146. * @returns the current bounding info
  7147. */
  7148. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7149. /**
  7150. * Scale the current bounding info by applying a scale factor
  7151. * @param factor defines the scale factor to apply
  7152. * @returns the current bounding info
  7153. */
  7154. scale(factor: number): BoundingInfo;
  7155. /**
  7156. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7157. * @param frustumPlanes defines the frustum to test
  7158. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7159. * @returns true if the bounding info is in the frustum planes
  7160. */
  7161. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7162. /**
  7163. * Gets the world distance between the min and max points of the bounding box
  7164. */
  7165. readonly diagonalLength: number;
  7166. /**
  7167. * Checks if a cullable object (mesh...) is in the camera frustum
  7168. * Unlike isInFrustum this cheks the full bounding box
  7169. * @param frustumPlanes Camera near/planes
  7170. * @returns true if the object is in frustum otherwise false
  7171. */
  7172. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7173. /** @hidden */ checkCollision(collider: Collider): boolean;
  7174. /**
  7175. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7176. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7177. * @param point the point to check intersection with
  7178. * @returns if the point intersects
  7179. */
  7180. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7181. /**
  7182. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7183. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7184. * @param boundingInfo the bounding info to check intersection with
  7185. * @param precise if the intersection should be done using OBB
  7186. * @returns if the bounding info intersects
  7187. */
  7188. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7189. }
  7190. }
  7191. declare module BABYLON {
  7192. /**
  7193. * Defines an array and its length.
  7194. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7195. */
  7196. export interface ISmartArrayLike<T> {
  7197. /**
  7198. * The data of the array.
  7199. */
  7200. data: Array<T>;
  7201. /**
  7202. * The active length of the array.
  7203. */
  7204. length: number;
  7205. }
  7206. /**
  7207. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7208. */
  7209. export class SmartArray<T> implements ISmartArrayLike<T> {
  7210. /**
  7211. * The full set of data from the array.
  7212. */
  7213. data: Array<T>;
  7214. /**
  7215. * The active length of the array.
  7216. */
  7217. length: number;
  7218. protected _id: number;
  7219. /**
  7220. * Instantiates a Smart Array.
  7221. * @param capacity defines the default capacity of the array.
  7222. */
  7223. constructor(capacity: number);
  7224. /**
  7225. * Pushes a value at the end of the active data.
  7226. * @param value defines the object to push in the array.
  7227. */
  7228. push(value: T): void;
  7229. /**
  7230. * Iterates over the active data and apply the lambda to them.
  7231. * @param func defines the action to apply on each value.
  7232. */
  7233. forEach(func: (content: T) => void): void;
  7234. /**
  7235. * Sorts the full sets of data.
  7236. * @param compareFn defines the comparison function to apply.
  7237. */
  7238. sort(compareFn: (a: T, b: T) => number): void;
  7239. /**
  7240. * Resets the active data to an empty array.
  7241. */
  7242. reset(): void;
  7243. /**
  7244. * Releases all the data from the array as well as the array.
  7245. */
  7246. dispose(): void;
  7247. /**
  7248. * Concats the active data with a given array.
  7249. * @param array defines the data to concatenate with.
  7250. */
  7251. concat(array: any): void;
  7252. /**
  7253. * Returns the position of a value in the active data.
  7254. * @param value defines the value to find the index for
  7255. * @returns the index if found in the active data otherwise -1
  7256. */
  7257. indexOf(value: T): number;
  7258. /**
  7259. * Returns whether an element is part of the active data.
  7260. * @param value defines the value to look for
  7261. * @returns true if found in the active data otherwise false
  7262. */
  7263. contains(value: T): boolean;
  7264. private static _GlobalId;
  7265. }
  7266. /**
  7267. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7268. * The data in this array can only be present once
  7269. */
  7270. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7271. private _duplicateId;
  7272. /**
  7273. * Pushes a value at the end of the active data.
  7274. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7275. * @param value defines the object to push in the array.
  7276. */
  7277. push(value: T): void;
  7278. /**
  7279. * Pushes a value at the end of the active data.
  7280. * If the data is already present, it won t be added again
  7281. * @param value defines the object to push in the array.
  7282. * @returns true if added false if it was already present
  7283. */
  7284. pushNoDuplicate(value: T): boolean;
  7285. /**
  7286. * Resets the active data to an empty array.
  7287. */
  7288. reset(): void;
  7289. /**
  7290. * Concats the active data with a given array.
  7291. * This ensures no dupplicate will be present in the result.
  7292. * @param array defines the data to concatenate with.
  7293. */
  7294. concatWithNoDuplicate(array: any): void;
  7295. }
  7296. }
  7297. declare module BABYLON {
  7298. /**
  7299. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7300. * separate meshes. This can be use to improve performances.
  7301. * @see http://doc.babylonjs.com/how_to/multi_materials
  7302. */
  7303. export class MultiMaterial extends Material {
  7304. private _subMaterials;
  7305. /**
  7306. * Gets or Sets the list of Materials used within the multi material.
  7307. * They need to be ordered according to the submeshes order in the associated mesh
  7308. */
  7309. subMaterials: Nullable<Material>[];
  7310. /**
  7311. * Function used to align with Node.getChildren()
  7312. * @returns the list of Materials used within the multi material
  7313. */
  7314. getChildren(): Nullable<Material>[];
  7315. /**
  7316. * Instantiates a new Multi Material
  7317. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7318. * separate meshes. This can be use to improve performances.
  7319. * @see http://doc.babylonjs.com/how_to/multi_materials
  7320. * @param name Define the name in the scene
  7321. * @param scene Define the scene the material belongs to
  7322. */
  7323. constructor(name: string, scene: Scene);
  7324. private _hookArray;
  7325. /**
  7326. * Get one of the submaterial by its index in the submaterials array
  7327. * @param index The index to look the sub material at
  7328. * @returns The Material if the index has been defined
  7329. */
  7330. getSubMaterial(index: number): Nullable<Material>;
  7331. /**
  7332. * Get the list of active textures for the whole sub materials list.
  7333. * @returns All the textures that will be used during the rendering
  7334. */
  7335. getActiveTextures(): BaseTexture[];
  7336. /**
  7337. * Gets the current class name of the material e.g. "MultiMaterial"
  7338. * Mainly use in serialization.
  7339. * @returns the class name
  7340. */
  7341. getClassName(): string;
  7342. /**
  7343. * Checks if the material is ready to render the requested sub mesh
  7344. * @param mesh Define the mesh the submesh belongs to
  7345. * @param subMesh Define the sub mesh to look readyness for
  7346. * @param useInstances Define whether or not the material is used with instances
  7347. * @returns true if ready, otherwise false
  7348. */
  7349. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7350. /**
  7351. * Clones the current material and its related sub materials
  7352. * @param name Define the name of the newly cloned material
  7353. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7354. * @returns the cloned material
  7355. */
  7356. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7357. /**
  7358. * Serializes the materials into a JSON representation.
  7359. * @returns the JSON representation
  7360. */
  7361. serialize(): any;
  7362. /**
  7363. * Dispose the material and release its associated resources
  7364. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  7365. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  7366. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7367. */
  7368. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7369. /**
  7370. * Creates a MultiMaterial from parsed MultiMaterial data.
  7371. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7372. * @param scene defines the hosting scene
  7373. * @returns a new MultiMaterial
  7374. */
  7375. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7376. }
  7377. }
  7378. declare module BABYLON {
  7379. /**
  7380. * Class used to represent data loading progression
  7381. */
  7382. export class SceneLoaderFlags {
  7383. private static _ForceFullSceneLoadingForIncremental;
  7384. private static _ShowLoadingScreen;
  7385. private static _CleanBoneMatrixWeights;
  7386. private static _loggingLevel;
  7387. /**
  7388. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7389. */
  7390. static ForceFullSceneLoadingForIncremental: boolean;
  7391. /**
  7392. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7393. */
  7394. static ShowLoadingScreen: boolean;
  7395. /**
  7396. * Defines the current logging level (while loading the scene)
  7397. * @ignorenaming
  7398. */
  7399. static loggingLevel: number;
  7400. /**
  7401. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7402. */
  7403. static CleanBoneMatrixWeights: boolean;
  7404. }
  7405. }
  7406. declare module BABYLON {
  7407. /**
  7408. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  7409. * @see https://doc.babylonjs.com/how_to/transformnode
  7410. */
  7411. export class TransformNode extends Node {
  7412. /**
  7413. * Object will not rotate to face the camera
  7414. */
  7415. static BILLBOARDMODE_NONE: number;
  7416. /**
  7417. * Object will rotate to face the camera but only on the x axis
  7418. */
  7419. static BILLBOARDMODE_X: number;
  7420. /**
  7421. * Object will rotate to face the camera but only on the y axis
  7422. */
  7423. static BILLBOARDMODE_Y: number;
  7424. /**
  7425. * Object will rotate to face the camera but only on the z axis
  7426. */
  7427. static BILLBOARDMODE_Z: number;
  7428. /**
  7429. * Object will rotate to face the camera
  7430. */
  7431. static BILLBOARDMODE_ALL: number;
  7432. private _forward;
  7433. private _forwardInverted;
  7434. private _up;
  7435. private _right;
  7436. private _rightInverted;
  7437. private _position;
  7438. private _rotation;
  7439. private _rotationQuaternion;
  7440. protected _scaling: Vector3;
  7441. protected _isDirty: boolean;
  7442. private _transformToBoneReferal;
  7443. private _billboardMode;
  7444. /**
  7445. * Gets or sets the billboard mode. Default is 0.
  7446. *
  7447. * | Value | Type | Description |
  7448. * | --- | --- | --- |
  7449. * | 0 | BILLBOARDMODE_NONE | |
  7450. * | 1 | BILLBOARDMODE_X | |
  7451. * | 2 | BILLBOARDMODE_Y | |
  7452. * | 4 | BILLBOARDMODE_Z | |
  7453. * | 7 | BILLBOARDMODE_ALL | |
  7454. *
  7455. */
  7456. billboardMode: number;
  7457. private _preserveParentRotationForBillboard;
  7458. /**
  7459. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7460. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7461. */
  7462. preserveParentRotationForBillboard: boolean;
  7463. /**
  7464. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  7465. */
  7466. scalingDeterminant: number;
  7467. private _infiniteDistance;
  7468. /**
  7469. * Gets or sets the distance of the object to max, often used by skybox
  7470. */
  7471. infiniteDistance: boolean;
  7472. /**
  7473. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7474. * By default the system will update normals to compensate
  7475. */
  7476. ignoreNonUniformScaling: boolean;
  7477. /**
  7478. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7479. */
  7480. reIntegrateRotationIntoRotationQuaternion: boolean;
  7481. /** @hidden */ poseMatrix: Nullable<Matrix>;
  7482. /** @hidden */ localMatrix: Matrix;
  7483. private _usePivotMatrix;
  7484. private _absolutePosition;
  7485. private _pivotMatrix;
  7486. private _pivotMatrixInverse;
  7487. protected _postMultiplyPivotMatrix: boolean;
  7488. protected _isWorldMatrixFrozen: boolean;
  7489. /** @hidden */ indexInSceneTransformNodesArray: number;
  7490. /**
  7491. * An event triggered after the world matrix is updated
  7492. */
  7493. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7494. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7495. /**
  7496. * Gets a string identifying the name of the class
  7497. * @returns "TransformNode" string
  7498. */
  7499. getClassName(): string;
  7500. /**
  7501. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7502. */
  7503. position: Vector3;
  7504. /**
  7505. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7506. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7507. */
  7508. rotation: Vector3;
  7509. /**
  7510. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7511. */
  7512. scaling: Vector3;
  7513. /**
  7514. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7515. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7516. */
  7517. rotationQuaternion: Nullable<Quaternion>;
  7518. /**
  7519. * The forward direction of that transform in world space.
  7520. */
  7521. readonly forward: Vector3;
  7522. /**
  7523. * The up direction of that transform in world space.
  7524. */
  7525. readonly up: Vector3;
  7526. /**
  7527. * The right direction of that transform in world space.
  7528. */
  7529. readonly right: Vector3;
  7530. /**
  7531. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7532. * @param matrix the matrix to copy the pose from
  7533. * @returns this TransformNode.
  7534. */
  7535. updatePoseMatrix(matrix: Matrix): TransformNode;
  7536. /**
  7537. * Returns the mesh Pose matrix.
  7538. * @returns the pose matrix
  7539. */
  7540. getPoseMatrix(): Matrix;
  7541. /** @hidden */ isSynchronized(): boolean;
  7542. /** @hidden */ initCache(): void;
  7543. /**
  7544. * Flag the transform node as dirty (Forcing it to update everything)
  7545. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7546. * @returns this transform node
  7547. */
  7548. markAsDirty(property: string): TransformNode;
  7549. /**
  7550. * Returns the current mesh absolute position.
  7551. * Returns a Vector3.
  7552. */
  7553. readonly absolutePosition: Vector3;
  7554. /**
  7555. * Sets a new matrix to apply before all other transformation
  7556. * @param matrix defines the transform matrix
  7557. * @returns the current TransformNode
  7558. */
  7559. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7560. /**
  7561. * Sets a new pivot matrix to the current node
  7562. * @param matrix defines the new pivot matrix to use
  7563. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  7564. * @returns the current TransformNode
  7565. */
  7566. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7567. /**
  7568. * Returns the mesh pivot matrix.
  7569. * Default : Identity.
  7570. * @returns the matrix
  7571. */
  7572. getPivotMatrix(): Matrix;
  7573. /**
  7574. * Prevents the World matrix to be computed any longer.
  7575. * @returns the TransformNode.
  7576. */
  7577. freezeWorldMatrix(): TransformNode;
  7578. /**
  7579. * Allows back the World matrix computation.
  7580. * @returns the TransformNode.
  7581. */
  7582. unfreezeWorldMatrix(): this;
  7583. /**
  7584. * True if the World matrix has been frozen.
  7585. */
  7586. readonly isWorldMatrixFrozen: boolean;
  7587. /**
  7588. * Retuns the mesh absolute position in the World.
  7589. * @returns a Vector3.
  7590. */
  7591. getAbsolutePosition(): Vector3;
  7592. /**
  7593. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7594. * @param absolutePosition the absolute position to set
  7595. * @returns the TransformNode.
  7596. */
  7597. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7598. /**
  7599. * Sets the mesh position in its local space.
  7600. * @param vector3 the position to set in localspace
  7601. * @returns the TransformNode.
  7602. */
  7603. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7604. /**
  7605. * Returns the mesh position in the local space from the current World matrix values.
  7606. * @returns a new Vector3.
  7607. */
  7608. getPositionExpressedInLocalSpace(): Vector3;
  7609. /**
  7610. * Translates the mesh along the passed Vector3 in its local space.
  7611. * @param vector3 the distance to translate in localspace
  7612. * @returns the TransformNode.
  7613. */
  7614. locallyTranslate(vector3: Vector3): TransformNode;
  7615. private static _lookAtVectorCache;
  7616. /**
  7617. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7618. * @param targetPoint the position (must be in same space as current mesh) to look at
  7619. * @param yawCor optional yaw (y-axis) correction in radians
  7620. * @param pitchCor optional pitch (x-axis) correction in radians
  7621. * @param rollCor optional roll (z-axis) correction in radians
  7622. * @param space the choosen space of the target
  7623. * @returns the TransformNode.
  7624. */
  7625. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7626. /**
  7627. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7628. * This Vector3 is expressed in the World space.
  7629. * @param localAxis axis to rotate
  7630. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7631. */
  7632. getDirection(localAxis: Vector3): Vector3;
  7633. /**
  7634. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7635. * localAxis is expressed in the mesh local space.
  7636. * result is computed in the Wordl space from the mesh World matrix.
  7637. * @param localAxis axis to rotate
  7638. * @param result the resulting transformnode
  7639. * @returns this TransformNode.
  7640. */
  7641. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7642. /**
  7643. * Sets this transform node rotation to the given local axis.
  7644. * @param localAxis the axis in local space
  7645. * @param yawCor optional yaw (y-axis) correction in radians
  7646. * @param pitchCor optional pitch (x-axis) correction in radians
  7647. * @param rollCor optional roll (z-axis) correction in radians
  7648. * @returns this TransformNode
  7649. */
  7650. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7651. /**
  7652. * Sets a new pivot point to the current node
  7653. * @param point defines the new pivot point to use
  7654. * @param space defines if the point is in world or local space (local by default)
  7655. * @returns the current TransformNode
  7656. */
  7657. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7658. /**
  7659. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7660. * @returns the pivot point
  7661. */
  7662. getPivotPoint(): Vector3;
  7663. /**
  7664. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7665. * @param result the vector3 to store the result
  7666. * @returns this TransformNode.
  7667. */
  7668. getPivotPointToRef(result: Vector3): TransformNode;
  7669. /**
  7670. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7671. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7672. */
  7673. getAbsolutePivotPoint(): Vector3;
  7674. /**
  7675. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7676. * @param result vector3 to store the result
  7677. * @returns this TransformNode.
  7678. */
  7679. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7680. /**
  7681. * Defines the passed node as the parent of the current node.
  7682. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7683. * @see https://doc.babylonjs.com/how_to/parenting
  7684. * @param node the node ot set as the parent
  7685. * @returns this TransformNode.
  7686. */
  7687. setParent(node: Nullable<Node>): TransformNode;
  7688. private _nonUniformScaling;
  7689. /**
  7690. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7691. */
  7692. readonly nonUniformScaling: boolean;
  7693. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  7694. /**
  7695. * Attach the current TransformNode to another TransformNode associated with a bone
  7696. * @param bone Bone affecting the TransformNode
  7697. * @param affectedTransformNode TransformNode associated with the bone
  7698. * @returns this object
  7699. */
  7700. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7701. /**
  7702. * Detach the transform node if its associated with a bone
  7703. * @returns this object
  7704. */
  7705. detachFromBone(): TransformNode;
  7706. private static _rotationAxisCache;
  7707. /**
  7708. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7709. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7710. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7711. * The passed axis is also normalized.
  7712. * @param axis the axis to rotate around
  7713. * @param amount the amount to rotate in radians
  7714. * @param space Space to rotate in (Default: local)
  7715. * @returns the TransformNode.
  7716. */
  7717. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7718. /**
  7719. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7720. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7721. * The passed axis is also normalized. .
  7722. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7723. * @param point the point to rotate around
  7724. * @param axis the axis to rotate around
  7725. * @param amount the amount to rotate in radians
  7726. * @returns the TransformNode
  7727. */
  7728. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7729. /**
  7730. * Translates the mesh along the axis vector for the passed distance in the given space.
  7731. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7732. * @param axis the axis to translate in
  7733. * @param distance the distance to translate
  7734. * @param space Space to rotate in (Default: local)
  7735. * @returns the TransformNode.
  7736. */
  7737. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7738. /**
  7739. * Adds a rotation step to the mesh current rotation.
  7740. * x, y, z are Euler angles expressed in radians.
  7741. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7742. * This means this rotation is made in the mesh local space only.
  7743. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7744. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7745. * ```javascript
  7746. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7747. * ```
  7748. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7749. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  7750. * @param x Rotation to add
  7751. * @param y Rotation to add
  7752. * @param z Rotation to add
  7753. * @returns the TransformNode.
  7754. */
  7755. addRotation(x: number, y: number, z: number): TransformNode;
  7756. /**
  7757. * @hidden
  7758. */
  7759. protected _getEffectiveParent(): Nullable<Node>;
  7760. /**
  7761. * Computes the world matrix of the node
  7762. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7763. * @returns the world matrix
  7764. */
  7765. computeWorldMatrix(force?: boolean): Matrix;
  7766. protected _afterComputeWorldMatrix(): void;
  7767. /**
  7768. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7769. * @param func callback function to add
  7770. *
  7771. * @returns the TransformNode.
  7772. */
  7773. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7774. /**
  7775. * Removes a registered callback function.
  7776. * @param func callback function to remove
  7777. * @returns the TransformNode.
  7778. */
  7779. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7780. /**
  7781. * Gets the position of the current mesh in camera space
  7782. * @param camera defines the camera to use
  7783. * @returns a position
  7784. */
  7785. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7786. /**
  7787. * Returns the distance from the mesh to the active camera
  7788. * @param camera defines the camera to use
  7789. * @returns the distance
  7790. */
  7791. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7792. /**
  7793. * Clone the current transform node
  7794. * @param name Name of the new clone
  7795. * @param newParent New parent for the clone
  7796. * @param doNotCloneChildren Do not clone children hierarchy
  7797. * @returns the new transform node
  7798. */
  7799. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7800. /**
  7801. * Serializes the objects information.
  7802. * @param currentSerializationObject defines the object to serialize in
  7803. * @returns the serialized object
  7804. */
  7805. serialize(currentSerializationObject?: any): any;
  7806. /**
  7807. * Returns a new TransformNode object parsed from the source provided.
  7808. * @param parsedTransformNode is the source.
  7809. * @param scene the scne the object belongs to
  7810. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7811. * @returns a new TransformNode object parsed from the source provided.
  7812. */
  7813. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7814. /**
  7815. * Get all child-transformNodes of this node
  7816. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  7817. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  7818. * @returns an array of TransformNode
  7819. */
  7820. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7821. /**
  7822. * Releases resources associated with this transform node.
  7823. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7824. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7825. */
  7826. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7827. }
  7828. }
  7829. declare module BABYLON {
  7830. /**
  7831. * Class used to override all child animations of a given target
  7832. */
  7833. export class AnimationPropertiesOverride {
  7834. /**
  7835. * Gets or sets a value indicating if animation blending must be used
  7836. */
  7837. enableBlending: boolean;
  7838. /**
  7839. * Gets or sets the blending speed to use when enableBlending is true
  7840. */
  7841. blendingSpeed: number;
  7842. /**
  7843. * Gets or sets the default loop mode to use
  7844. */
  7845. loopMode: number;
  7846. }
  7847. }
  7848. declare module BABYLON {
  7849. /**
  7850. * Class used to store bone information
  7851. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7852. */
  7853. export class Bone extends Node {
  7854. /**
  7855. * defines the bone name
  7856. */
  7857. name: string;
  7858. private static _tmpVecs;
  7859. private static _tmpQuat;
  7860. private static _tmpMats;
  7861. /**
  7862. * Gets the list of child bones
  7863. */
  7864. children: Bone[];
  7865. /** Gets the animations associated with this bone */
  7866. animations: Animation[];
  7867. /**
  7868. * Gets or sets bone length
  7869. */
  7870. length: number;
  7871. /**
  7872. * @hidden Internal only
  7873. * Set this value to map this bone to a different index in the transform matrices
  7874. * Set this value to -1 to exclude the bone from the transform matrices
  7875. */ index: Nullable<number>;
  7876. private _skeleton;
  7877. private _localMatrix;
  7878. private _restPose;
  7879. private _baseMatrix;
  7880. private _absoluteTransform;
  7881. private _invertedAbsoluteTransform;
  7882. private _parent;
  7883. private _scalingDeterminant;
  7884. private _worldTransform;
  7885. private _localScaling;
  7886. private _localRotation;
  7887. private _localPosition;
  7888. private _needToDecompose;
  7889. private _needToCompose;
  7890. /** @hidden */ linkedTransformNode: Nullable<TransformNode>;
  7891. /** @hidden */
  7892. /** @hidden */ matrix: Matrix;
  7893. /**
  7894. * Create a new bone
  7895. * @param name defines the bone name
  7896. * @param skeleton defines the parent skeleton
  7897. * @param parentBone defines the parent (can be null if the bone is the root)
  7898. * @param localMatrix defines the local matrix
  7899. * @param restPose defines the rest pose matrix
  7900. * @param baseMatrix defines the base matrix
  7901. * @param index defines index of the bone in the hiearchy
  7902. */
  7903. constructor(
  7904. /**
  7905. * defines the bone name
  7906. */
  7907. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7908. /**
  7909. * Gets the current object class name.
  7910. * @return the class name
  7911. */
  7912. getClassName(): string;
  7913. /**
  7914. * Gets the parent skeleton
  7915. * @returns a skeleton
  7916. */
  7917. getSkeleton(): Skeleton;
  7918. /**
  7919. * Gets parent bone
  7920. * @returns a bone or null if the bone is the root of the bone hierarchy
  7921. */
  7922. getParent(): Nullable<Bone>;
  7923. /**
  7924. * Returns an array containing the root bones
  7925. * @returns an array containing the root bones
  7926. */
  7927. getChildren(): Array<Bone>;
  7928. /**
  7929. * Sets the parent bone
  7930. * @param parent defines the parent (can be null if the bone is the root)
  7931. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7932. */
  7933. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7934. /**
  7935. * Gets the local matrix
  7936. * @returns a matrix
  7937. */
  7938. getLocalMatrix(): Matrix;
  7939. /**
  7940. * Gets the base matrix (initial matrix which remains unchanged)
  7941. * @returns a matrix
  7942. */
  7943. getBaseMatrix(): Matrix;
  7944. /**
  7945. * Gets the rest pose matrix
  7946. * @returns a matrix
  7947. */
  7948. getRestPose(): Matrix;
  7949. /**
  7950. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7951. */
  7952. getWorldMatrix(): Matrix;
  7953. /**
  7954. * Sets the local matrix to rest pose matrix
  7955. */
  7956. returnToRest(): void;
  7957. /**
  7958. * Gets the inverse of the absolute transform matrix.
  7959. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7960. * @returns a matrix
  7961. */
  7962. getInvertedAbsoluteTransform(): Matrix;
  7963. /**
  7964. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7965. * @returns a matrix
  7966. */
  7967. getAbsoluteTransform(): Matrix;
  7968. /**
  7969. * Links with the given transform node.
  7970. * The local matrix of this bone is copied from the transform node every frame.
  7971. * @param transformNode defines the transform node to link to
  7972. */
  7973. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7974. /** Gets or sets current position (in local space) */
  7975. position: Vector3;
  7976. /** Gets or sets current rotation (in local space) */
  7977. rotation: Vector3;
  7978. /** Gets or sets current rotation quaternion (in local space) */
  7979. rotationQuaternion: Quaternion;
  7980. /** Gets or sets current scaling (in local space) */
  7981. scaling: Vector3;
  7982. /**
  7983. * Gets the animation properties override
  7984. */
  7985. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7986. private _decompose;
  7987. private _compose;
  7988. /**
  7989. * Update the base and local matrices
  7990. * @param matrix defines the new base or local matrix
  7991. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7992. * @param updateLocalMatrix defines if the local matrix should be updated
  7993. */
  7994. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  7995. /** @hidden */ updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  7996. /**
  7997. * Flag the bone as dirty (Forcing it to update everything)
  7998. */
  7999. markAsDirty(): void;
  8000. private _markAsDirtyAndCompose;
  8001. private _markAsDirtyAndDecompose;
  8002. /**
  8003. * Translate the bone in local or world space
  8004. * @param vec The amount to translate the bone
  8005. * @param space The space that the translation is in
  8006. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8007. */
  8008. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8009. /**
  8010. * Set the postion of the bone in local or world space
  8011. * @param position The position to set the bone
  8012. * @param space The space that the position is in
  8013. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8014. */
  8015. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8016. /**
  8017. * Set the absolute position of the bone (world space)
  8018. * @param position The position to set the bone
  8019. * @param mesh The mesh that this bone is attached to
  8020. */
  8021. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8022. /**
  8023. * Scale the bone on the x, y and z axes (in local space)
  8024. * @param x The amount to scale the bone on the x axis
  8025. * @param y The amount to scale the bone on the y axis
  8026. * @param z The amount to scale the bone on the z axis
  8027. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8028. */
  8029. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8030. /**
  8031. * Set the bone scaling in local space
  8032. * @param scale defines the scaling vector
  8033. */
  8034. setScale(scale: Vector3): void;
  8035. /**
  8036. * Gets the current scaling in local space
  8037. * @returns the current scaling vector
  8038. */
  8039. getScale(): Vector3;
  8040. /**
  8041. * Gets the current scaling in local space and stores it in a target vector
  8042. * @param result defines the target vector
  8043. */
  8044. getScaleToRef(result: Vector3): void;
  8045. /**
  8046. * Set the yaw, pitch, and roll of the bone in local or world space
  8047. * @param yaw The rotation of the bone on the y axis
  8048. * @param pitch The rotation of the bone on the x axis
  8049. * @param roll The rotation of the bone on the z axis
  8050. * @param space The space that the axes of rotation are in
  8051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8052. */
  8053. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8054. /**
  8055. * Add a rotation to the bone on an axis in local or world space
  8056. * @param axis The axis to rotate the bone on
  8057. * @param amount The amount to rotate the bone
  8058. * @param space The space that the axis is in
  8059. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8060. */
  8061. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8062. /**
  8063. * Set the rotation of the bone to a particular axis angle in local or world space
  8064. * @param axis The axis to rotate the bone on
  8065. * @param angle The angle that the bone should be rotated to
  8066. * @param space The space that the axis is in
  8067. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8068. */
  8069. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8070. /**
  8071. * Set the euler rotation of the bone in local of world space
  8072. * @param rotation The euler rotation that the bone should be set to
  8073. * @param space The space that the rotation is in
  8074. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8075. */
  8076. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8077. /**
  8078. * Set the quaternion rotation of the bone in local of world space
  8079. * @param quat The quaternion rotation that the bone should be set to
  8080. * @param space The space that the rotation is in
  8081. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8082. */
  8083. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8084. /**
  8085. * Set the rotation matrix of the bone in local of world space
  8086. * @param rotMat The rotation matrix that the bone should be set to
  8087. * @param space The space that the rotation is in
  8088. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8089. */
  8090. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8091. private _rotateWithMatrix;
  8092. private _getNegativeRotationToRef;
  8093. /**
  8094. * Get the position of the bone in local or world space
  8095. * @param space The space that the returned position is in
  8096. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8097. * @returns The position of the bone
  8098. */
  8099. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8100. /**
  8101. * Copy the position of the bone to a vector3 in local or world space
  8102. * @param space The space that the returned position is in
  8103. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8104. * @param result The vector3 to copy the position to
  8105. */
  8106. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8107. /**
  8108. * Get the absolute position of the bone (world space)
  8109. * @param mesh The mesh that this bone is attached to
  8110. * @returns The absolute position of the bone
  8111. */
  8112. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8113. /**
  8114. * Copy the absolute position of the bone (world space) to the result param
  8115. * @param mesh The mesh that this bone is attached to
  8116. * @param result The vector3 to copy the absolute position to
  8117. */
  8118. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8119. /**
  8120. * Compute the absolute transforms of this bone and its children
  8121. */
  8122. computeAbsoluteTransforms(): void;
  8123. /**
  8124. * Get the world direction from an axis that is in the local space of the bone
  8125. * @param localAxis The local direction that is used to compute the world direction
  8126. * @param mesh The mesh that this bone is attached to
  8127. * @returns The world direction
  8128. */
  8129. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8130. /**
  8131. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8132. * @param localAxis The local direction that is used to compute the world direction
  8133. * @param mesh The mesh that this bone is attached to
  8134. * @param result The vector3 that the world direction will be copied to
  8135. */
  8136. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8137. /**
  8138. * Get the euler rotation of the bone in local or world space
  8139. * @param space The space that the rotation should be in
  8140. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8141. * @returns The euler rotation
  8142. */
  8143. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8144. /**
  8145. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8146. * @param space The space that the rotation should be in
  8147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8148. * @param result The vector3 that the rotation should be copied to
  8149. */
  8150. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8151. /**
  8152. * Get the quaternion rotation of the bone in either local or world space
  8153. * @param space The space that the rotation should be in
  8154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8155. * @returns The quaternion rotation
  8156. */
  8157. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8158. /**
  8159. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8160. * @param space The space that the rotation should be in
  8161. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8162. * @param result The quaternion that the rotation should be copied to
  8163. */
  8164. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8165. /**
  8166. * Get the rotation matrix of the bone in local or world space
  8167. * @param space The space that the rotation should be in
  8168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8169. * @returns The rotation matrix
  8170. */
  8171. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8172. /**
  8173. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8174. * @param space The space that the rotation should be in
  8175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8176. * @param result The quaternion that the rotation should be copied to
  8177. */
  8178. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8179. /**
  8180. * Get the world position of a point that is in the local space of the bone
  8181. * @param position The local position
  8182. * @param mesh The mesh that this bone is attached to
  8183. * @returns The world position
  8184. */
  8185. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8186. /**
  8187. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8188. * @param position The local position
  8189. * @param mesh The mesh that this bone is attached to
  8190. * @param result The vector3 that the world position should be copied to
  8191. */
  8192. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8193. /**
  8194. * Get the local position of a point that is in world space
  8195. * @param position The world position
  8196. * @param mesh The mesh that this bone is attached to
  8197. * @returns The local position
  8198. */
  8199. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8200. /**
  8201. * Get the local position of a point that is in world space and copy it to the result param
  8202. * @param position The world position
  8203. * @param mesh The mesh that this bone is attached to
  8204. * @param result The vector3 that the local position should be copied to
  8205. */
  8206. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8207. }
  8208. }
  8209. declare module BABYLON {
  8210. /**
  8211. * Enum that determines the text-wrapping mode to use.
  8212. */
  8213. export enum InspectableType {
  8214. /**
  8215. * Checkbox for booleans
  8216. */
  8217. Checkbox = 0,
  8218. /**
  8219. * Sliders for numbers
  8220. */
  8221. Slider = 1,
  8222. /**
  8223. * Vector3
  8224. */
  8225. Vector3 = 2,
  8226. /**
  8227. * Quaternions
  8228. */
  8229. Quaternion = 3,
  8230. /**
  8231. * Color3
  8232. */
  8233. Color3 = 4
  8234. }
  8235. /**
  8236. * Interface used to define custom inspectable properties.
  8237. * This interface is used by the inspector to display custom property grids
  8238. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8239. */
  8240. export interface IInspectable {
  8241. /**
  8242. * Gets the label to display
  8243. */
  8244. label: string;
  8245. /**
  8246. * Gets the name of the property to edit
  8247. */
  8248. propertyName: string;
  8249. /**
  8250. * Gets the type of the editor to use
  8251. */
  8252. type: InspectableType;
  8253. /**
  8254. * Gets the minimum value of the property when using in "slider" mode
  8255. */
  8256. min?: number;
  8257. /**
  8258. * Gets the maximum value of the property when using in "slider" mode
  8259. */
  8260. max?: number;
  8261. /**
  8262. * Gets the setp to use when using in "slider" mode
  8263. */
  8264. step?: number;
  8265. }
  8266. }
  8267. declare module BABYLON {
  8268. /**
  8269. * This represents the required contract to create a new type of texture loader.
  8270. */
  8271. export interface IInternalTextureLoader {
  8272. /**
  8273. * Defines wether the loader supports cascade loading the different faces.
  8274. */
  8275. supportCascades: boolean;
  8276. /**
  8277. * This returns if the loader support the current file information.
  8278. * @param extension defines the file extension of the file being loaded
  8279. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8280. * @param fallback defines the fallback internal texture if any
  8281. * @param isBase64 defines whether the texture is encoded as a base64
  8282. * @param isBuffer defines whether the texture data are stored as a buffer
  8283. * @returns true if the loader can load the specified file
  8284. */
  8285. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8286. /**
  8287. * Transform the url before loading if required.
  8288. * @param rootUrl the url of the texture
  8289. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8290. * @returns the transformed texture
  8291. */
  8292. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8293. /**
  8294. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8295. * @param rootUrl the url of the texture
  8296. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8297. * @returns the fallback texture
  8298. */
  8299. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8300. /**
  8301. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8302. * @param data contains the texture data
  8303. * @param texture defines the BabylonJS internal texture
  8304. * @param createPolynomials will be true if polynomials have been requested
  8305. * @param onLoad defines the callback to trigger once the texture is ready
  8306. * @param onError defines the callback to trigger in case of error
  8307. */
  8308. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8309. /**
  8310. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8311. * @param data contains the texture data
  8312. * @param texture defines the BabylonJS internal texture
  8313. * @param callback defines the method to call once ready to upload
  8314. */
  8315. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8316. }
  8317. }
  8318. declare module BABYLON {
  8319. interface Engine {
  8320. /**
  8321. * Creates a depth stencil cube texture.
  8322. * This is only available in WebGL 2.
  8323. * @param size The size of face edge in the cube texture.
  8324. * @param options The options defining the cube texture.
  8325. * @returns The cube texture
  8326. */ createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8327. /**
  8328. * Creates a cube texture
  8329. * @param rootUrl defines the url where the files to load is located
  8330. * @param scene defines the current scene
  8331. * @param files defines the list of files to load (1 per face)
  8332. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8333. * @param onLoad defines an optional callback raised when the texture is loaded
  8334. * @param onError defines an optional callback raised if there is an issue to load the texture
  8335. * @param format defines the format of the data
  8336. * @param forcedExtension defines the extension to use to pick the right loader
  8337. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8338. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8339. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8340. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8341. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8342. * @returns the cube texture as an InternalTexture
  8343. */
  8344. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8345. /**
  8346. * Creates a cube texture
  8347. * @param rootUrl defines the url where the files to load is located
  8348. * @param scene defines the current scene
  8349. * @param files defines the list of files to load (1 per face)
  8350. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8351. * @param onLoad defines an optional callback raised when the texture is loaded
  8352. * @param onError defines an optional callback raised if there is an issue to load the texture
  8353. * @param format defines the format of the data
  8354. * @param forcedExtension defines the extension to use to pick the right loader
  8355. * @returns the cube texture as an InternalTexture
  8356. */
  8357. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  8358. /**
  8359. * Creates a cube texture
  8360. * @param rootUrl defines the url where the files to load is located
  8361. * @param scene defines the current scene
  8362. * @param files defines the list of files to load (1 per face)
  8363. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8364. * @param onLoad defines an optional callback raised when the texture is loaded
  8365. * @param onError defines an optional callback raised if there is an issue to load the texture
  8366. * @param format defines the format of the data
  8367. * @param forcedExtension defines the extension to use to pick the right loader
  8368. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8369. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8370. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8371. * @returns the cube texture as an InternalTexture
  8372. */
  8373. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8374. /** @hidden */ partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8375. /** @hidden */ cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8376. /** @hidden */ cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8377. /** @hidden */ partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8378. }
  8379. }
  8380. declare module BABYLON {
  8381. /**
  8382. * Class for creating a cube texture
  8383. */
  8384. export class CubeTexture extends BaseTexture {
  8385. private _delayedOnLoad;
  8386. /**
  8387. * The url of the texture
  8388. */
  8389. url: string;
  8390. /**
  8391. * Gets or sets the center of the bounding box associated with the cube texture.
  8392. * It must define where the camera used to render the texture was set
  8393. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8394. */
  8395. boundingBoxPosition: Vector3;
  8396. private _boundingBoxSize;
  8397. /**
  8398. * Gets or sets the size of the bounding box associated with the cube texture
  8399. * When defined, the cubemap will switch to local mode
  8400. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8401. * @example https://www.babylonjs-playground.com/#RNASML
  8402. */
  8403. /**
  8404. * Returns the bounding box size
  8405. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8406. */
  8407. boundingBoxSize: Vector3;
  8408. protected _rotationY: number;
  8409. /**
  8410. * Sets texture matrix rotation angle around Y axis in radians.
  8411. */
  8412. /**
  8413. * Gets texture matrix rotation angle around Y axis radians.
  8414. */
  8415. rotationY: number;
  8416. /**
  8417. * Are mip maps generated for this texture or not.
  8418. */
  8419. readonly noMipmap: boolean;
  8420. private _noMipmap;
  8421. private _files;
  8422. private _extensions;
  8423. private _textureMatrix;
  8424. private _format;
  8425. private _createPolynomials;
  8426. /** @hidden */ prefiltered: boolean;
  8427. /**
  8428. * Creates a cube texture from an array of image urls
  8429. * @param files defines an array of image urls
  8430. * @param scene defines the hosting scene
  8431. * @param noMipmap specifies if mip maps are not used
  8432. * @returns a cube texture
  8433. */
  8434. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8435. /**
  8436. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8437. * @param url defines the url of the prefiltered texture
  8438. * @param scene defines the scene the texture is attached to
  8439. * @param forcedExtension defines the extension of the file if different from the url
  8440. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8441. * @return the prefiltered texture
  8442. */
  8443. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8444. /**
  8445. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8446. * as prefiltered data.
  8447. * @param rootUrl defines the url of the texture or the root name of the six images
  8448. * @param scene defines the scene the texture is attached to
  8449. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8450. * @param noMipmap defines if mipmaps should be created or not
  8451. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8452. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8453. * @param onError defines a callback triggered in case of error during load
  8454. * @param format defines the internal format to use for the texture once loaded
  8455. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8456. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8457. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8458. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8459. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8460. * @return the cube texture
  8461. */
  8462. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  8463. /**
  8464. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8465. */
  8466. readonly isPrefiltered: boolean;
  8467. /**
  8468. * Get the current class name of the texture useful for serialization or dynamic coding.
  8469. * @returns "CubeTexture"
  8470. */
  8471. getClassName(): string;
  8472. /**
  8473. * Update the url (and optional buffer) of this texture if url was null during construction.
  8474. * @param url the url of the texture
  8475. * @param forcedExtension defines the extension to use
  8476. * @param onLoad callback called when the texture is loaded (defaults to null)
  8477. */
  8478. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8479. /**
  8480. * Delays loading of the cube texture
  8481. * @param forcedExtension defines the extension to use
  8482. */
  8483. delayLoad(forcedExtension?: string): void;
  8484. /**
  8485. * Returns the reflection texture matrix
  8486. * @returns the reflection texture matrix
  8487. */
  8488. getReflectionTextureMatrix(): Matrix;
  8489. /**
  8490. * Sets the reflection texture matrix
  8491. * @param value Reflection texture matrix
  8492. */
  8493. setReflectionTextureMatrix(value: Matrix): void;
  8494. /**
  8495. * Parses text to create a cube texture
  8496. * @param parsedTexture define the serialized text to read from
  8497. * @param scene defines the hosting scene
  8498. * @param rootUrl defines the root url of the cube texture
  8499. * @returns a cube texture
  8500. */
  8501. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8502. /**
  8503. * Makes a clone, or deep copy, of the cube texture
  8504. * @returns a new cube texture
  8505. */
  8506. clone(): CubeTexture;
  8507. }
  8508. }
  8509. declare module BABYLON {
  8510. /** @hidden */
  8511. export var postprocessVertexShader: {
  8512. name: string;
  8513. shader: string;
  8514. };
  8515. }
  8516. declare module BABYLON {
  8517. /**
  8518. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8519. * This is the base of the follow, arc rotate cameras and Free camera
  8520. * @see http://doc.babylonjs.com/features/cameras
  8521. */
  8522. export class TargetCamera extends Camera {
  8523. private static _RigCamTransformMatrix;
  8524. private static _TargetTransformMatrix;
  8525. private static _TargetFocalPoint;
  8526. /**
  8527. * Define the current direction the camera is moving to
  8528. */
  8529. cameraDirection: Vector3;
  8530. /**
  8531. * Define the current rotation the camera is rotating to
  8532. */
  8533. cameraRotation: Vector2;
  8534. /**
  8535. * When set, the up vector of the camera will be updated by the rotation of the camera
  8536. */
  8537. updateUpVectorFromRotation: boolean;
  8538. private _tmpQuaternion;
  8539. /**
  8540. * Define the current rotation of the camera
  8541. */
  8542. rotation: Vector3;
  8543. /**
  8544. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8545. */
  8546. rotationQuaternion: Quaternion;
  8547. /**
  8548. * Define the current speed of the camera
  8549. */
  8550. speed: number;
  8551. /**
  8552. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8553. * around all axis.
  8554. */
  8555. noRotationConstraint: boolean;
  8556. /**
  8557. * Define the current target of the camera as an object or a position.
  8558. */
  8559. lockedTarget: any;
  8560. /** @hidden */ currentTarget: Vector3;
  8561. /** @hidden */ initialFocalDistance: number;
  8562. /** @hidden */ viewMatrix: Matrix;
  8563. /** @hidden */ camMatrix: Matrix;
  8564. /** @hidden */ cameraTransformMatrix: Matrix;
  8565. /** @hidden */ cameraRotationMatrix: Matrix;
  8566. /** @hidden */ referencePoint: Vector3;
  8567. /** @hidden */ transformedReferencePoint: Vector3;
  8568. protected _globalCurrentTarget: Vector3;
  8569. protected _globalCurrentUpVector: Vector3;
  8570. /** @hidden */ reset: () => void;
  8571. private _defaultUp;
  8572. /**
  8573. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8574. * This is the base of the follow, arc rotate cameras and Free camera
  8575. * @see http://doc.babylonjs.com/features/cameras
  8576. * @param name Defines the name of the camera in the scene
  8577. * @param position Defines the start position of the camera in the scene
  8578. * @param scene Defines the scene the camera belongs to
  8579. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8580. */
  8581. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8582. /**
  8583. * Gets the position in front of the camera at a given distance.
  8584. * @param distance The distance from the camera we want the position to be
  8585. * @returns the position
  8586. */
  8587. getFrontPosition(distance: number): Vector3;
  8588. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  8589. private _storedPosition;
  8590. private _storedRotation;
  8591. private _storedRotationQuaternion;
  8592. /**
  8593. * Store current camera state of the camera (fov, position, rotation, etc..)
  8594. * @returns the camera
  8595. */
  8596. storeState(): Camera;
  8597. /**
  8598. * Restored camera state. You must call storeState() first
  8599. * @returns whether it was successful or not
  8600. * @hidden
  8601. */ restoreStateValues(): boolean;
  8602. /** @hidden */ initCache(): void;
  8603. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  8604. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  8605. /** @hidden */ computeLocalCameraSpeed(): number;
  8606. /**
  8607. * Defines the target the camera should look at.
  8608. * This will automatically adapt alpha beta and radius to fit within the new target.
  8609. * @param target Defines the new target as a Vector or a mesh
  8610. */
  8611. setTarget(target: Vector3): void;
  8612. /**
  8613. * Return the current target position of the camera. This value is expressed in local space.
  8614. * @returns the target position
  8615. */
  8616. getTarget(): Vector3;
  8617. /** @hidden */ decideIfNeedsToMove(): boolean;
  8618. /** @hidden */ updatePosition(): void;
  8619. /** @hidden */ checkInputs(): void;
  8620. protected _updateCameraRotationMatrix(): void;
  8621. /**
  8622. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8623. * @returns the current camera
  8624. */
  8625. private _rotateUpVectorWithCameraRotationMatrix;
  8626. private _cachedRotationZ;
  8627. private _cachedQuaternionRotationZ;
  8628. /** @hidden */ getViewMatrix(): Matrix;
  8629. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8630. /**
  8631. * @hidden
  8632. */
  8633. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8634. /**
  8635. * @hidden
  8636. */ updateRigCameras(): void;
  8637. private _getRigCamPositionAndTarget;
  8638. /**
  8639. * Gets the current object class name.
  8640. * @return the class name
  8641. */
  8642. getClassName(): string;
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * @ignore
  8648. * This is a list of all the different input types that are available in the application.
  8649. * Fo instance: ArcRotateCameraGamepadInput...
  8650. */
  8651. export var CameraInputTypes: {};
  8652. /**
  8653. * This is the contract to implement in order to create a new input class.
  8654. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8655. */
  8656. export interface ICameraInput<TCamera extends Camera> {
  8657. /**
  8658. * Defines the camera the input is attached to.
  8659. */
  8660. camera: Nullable<TCamera>;
  8661. /**
  8662. * Gets the class name of the current intput.
  8663. * @returns the class name
  8664. */
  8665. getClassName(): string;
  8666. /**
  8667. * Get the friendly name associated with the input class.
  8668. * @returns the input friendly name
  8669. */
  8670. getSimpleName(): string;
  8671. /**
  8672. * Attach the input controls to a specific dom element to get the input from.
  8673. * @param element Defines the element the controls should be listened from
  8674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8675. */
  8676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8677. /**
  8678. * Detach the current controls from the specified dom element.
  8679. * @param element Defines the element to stop listening the inputs from
  8680. */
  8681. detachControl(element: Nullable<HTMLElement>): void;
  8682. /**
  8683. * Update the current camera state depending on the inputs that have been used this frame.
  8684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8685. */
  8686. checkInputs?: () => void;
  8687. }
  8688. /**
  8689. * Represents a map of input types to input instance or input index to input instance.
  8690. */
  8691. export interface CameraInputsMap<TCamera extends Camera> {
  8692. /**
  8693. * Accessor to the input by input type.
  8694. */
  8695. [name: string]: ICameraInput<TCamera>;
  8696. /**
  8697. * Accessor to the input by input index.
  8698. */
  8699. [idx: number]: ICameraInput<TCamera>;
  8700. }
  8701. /**
  8702. * This represents the input manager used within a camera.
  8703. * It helps dealing with all the different kind of input attached to a camera.
  8704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8705. */
  8706. export class CameraInputsManager<TCamera extends Camera> {
  8707. /**
  8708. * Defines the list of inputs attahed to the camera.
  8709. */
  8710. attached: CameraInputsMap<TCamera>;
  8711. /**
  8712. * Defines the dom element the camera is collecting inputs from.
  8713. * This is null if the controls have not been attached.
  8714. */
  8715. attachedElement: Nullable<HTMLElement>;
  8716. /**
  8717. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8718. */
  8719. noPreventDefault: boolean;
  8720. /**
  8721. * Defined the camera the input manager belongs to.
  8722. */
  8723. camera: TCamera;
  8724. /**
  8725. * Update the current camera state depending on the inputs that have been used this frame.
  8726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8727. */
  8728. checkInputs: () => void;
  8729. /**
  8730. * Instantiate a new Camera Input Manager.
  8731. * @param camera Defines the camera the input manager blongs to
  8732. */
  8733. constructor(camera: TCamera);
  8734. /**
  8735. * Add an input method to a camera
  8736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8737. * @param input camera input method
  8738. */
  8739. add(input: ICameraInput<TCamera>): void;
  8740. /**
  8741. * Remove a specific input method from a camera
  8742. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8743. * @param inputToRemove camera input method
  8744. */
  8745. remove(inputToRemove: ICameraInput<TCamera>): void;
  8746. /**
  8747. * Remove a specific input type from a camera
  8748. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8749. * @param inputType the type of the input to remove
  8750. */
  8751. removeByType(inputType: string): void;
  8752. private _addCheckInputs;
  8753. /**
  8754. * Attach the input controls to the currently attached dom element to listen the events from.
  8755. * @param input Defines the input to attach
  8756. */
  8757. attachInput(input: ICameraInput<TCamera>): void;
  8758. /**
  8759. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8760. * @param element Defines the dom element to collect the events from
  8761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8762. */
  8763. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8764. /**
  8765. * Detach the current manager inputs controls from a specific dom element.
  8766. * @param element Defines the dom element to collect the events from
  8767. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8768. */
  8769. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8770. /**
  8771. * Rebuild the dynamic inputCheck function from the current list of
  8772. * defined inputs in the manager.
  8773. */
  8774. rebuildInputCheck(): void;
  8775. /**
  8776. * Remove all attached input methods from a camera
  8777. */
  8778. clear(): void;
  8779. /**
  8780. * Serialize the current input manager attached to a camera.
  8781. * This ensures than once parsed,
  8782. * the input associated to the camera will be identical to the current ones
  8783. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8784. */
  8785. serialize(serializedCamera: any): void;
  8786. /**
  8787. * Parses an input manager serialized JSON to restore the previous list of inputs
  8788. * and states associated to a camera.
  8789. * @param parsedCamera Defines the JSON to parse
  8790. */
  8791. parse(parsedCamera: any): void;
  8792. }
  8793. }
  8794. declare module BABYLON {
  8795. /**
  8796. * Gather the list of keyboard event types as constants.
  8797. */
  8798. export class KeyboardEventTypes {
  8799. /**
  8800. * The keydown event is fired when a key becomes active (pressed).
  8801. */
  8802. static readonly KEYDOWN: number;
  8803. /**
  8804. * The keyup event is fired when a key has been released.
  8805. */
  8806. static readonly KEYUP: number;
  8807. }
  8808. /**
  8809. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8810. */
  8811. export class KeyboardInfo {
  8812. /**
  8813. * Defines the type of event (KeyboardEventTypes)
  8814. */
  8815. type: number;
  8816. /**
  8817. * Defines the related dom event
  8818. */
  8819. event: KeyboardEvent;
  8820. /**
  8821. * Instantiates a new keyboard info.
  8822. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8823. * @param type Defines the type of event (KeyboardEventTypes)
  8824. * @param event Defines the related dom event
  8825. */
  8826. constructor(
  8827. /**
  8828. * Defines the type of event (KeyboardEventTypes)
  8829. */
  8830. type: number,
  8831. /**
  8832. * Defines the related dom event
  8833. */
  8834. event: KeyboardEvent);
  8835. }
  8836. /**
  8837. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8838. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8839. */
  8840. export class KeyboardInfoPre extends KeyboardInfo {
  8841. /**
  8842. * Defines the type of event (KeyboardEventTypes)
  8843. */
  8844. type: number;
  8845. /**
  8846. * Defines the related dom event
  8847. */
  8848. event: KeyboardEvent;
  8849. /**
  8850. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8851. */
  8852. skipOnPointerObservable: boolean;
  8853. /**
  8854. * Instantiates a new keyboard pre info.
  8855. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8856. * @param type Defines the type of event (KeyboardEventTypes)
  8857. * @param event Defines the related dom event
  8858. */
  8859. constructor(
  8860. /**
  8861. * Defines the type of event (KeyboardEventTypes)
  8862. */
  8863. type: number,
  8864. /**
  8865. * Defines the related dom event
  8866. */
  8867. event: KeyboardEvent);
  8868. }
  8869. }
  8870. declare module BABYLON {
  8871. /**
  8872. * Manage the keyboard inputs to control the movement of a free camera.
  8873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8874. */
  8875. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8876. /**
  8877. * Defines the camera the input is attached to.
  8878. */
  8879. camera: FreeCamera;
  8880. /**
  8881. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8882. */
  8883. keysUp: number[];
  8884. /**
  8885. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8886. */
  8887. keysDown: number[];
  8888. /**
  8889. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8890. */
  8891. keysLeft: number[];
  8892. /**
  8893. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8894. */
  8895. keysRight: number[];
  8896. private _keys;
  8897. private _onCanvasBlurObserver;
  8898. private _onKeyboardObserver;
  8899. private _engine;
  8900. private _scene;
  8901. /**
  8902. * Attach the input controls to a specific dom element to get the input from.
  8903. * @param element Defines the element the controls should be listened from
  8904. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8905. */
  8906. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8907. /**
  8908. * Detach the current controls from the specified dom element.
  8909. * @param element Defines the element to stop listening the inputs from
  8910. */
  8911. detachControl(element: Nullable<HTMLElement>): void;
  8912. /**
  8913. * Update the current camera state depending on the inputs that have been used this frame.
  8914. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8915. */
  8916. checkInputs(): void;
  8917. /**
  8918. * Gets the class name of the current intput.
  8919. * @returns the class name
  8920. */
  8921. getClassName(): string;
  8922. /** @hidden */ onLostFocus(): void;
  8923. /**
  8924. * Get the friendly name associated with the input class.
  8925. * @returns the input friendly name
  8926. */
  8927. getSimpleName(): string;
  8928. }
  8929. }
  8930. declare module BABYLON {
  8931. /**
  8932. * Interface describing all the common properties and methods a shadow light needs to implement.
  8933. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8934. * as well as binding the different shadow properties to the effects.
  8935. */
  8936. export interface IShadowLight extends Light {
  8937. /**
  8938. * The light id in the scene (used in scene.findLighById for instance)
  8939. */
  8940. id: string;
  8941. /**
  8942. * The position the shdow will be casted from.
  8943. */
  8944. position: Vector3;
  8945. /**
  8946. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8947. */
  8948. direction: Vector3;
  8949. /**
  8950. * The transformed position. Position of the light in world space taking parenting in account.
  8951. */
  8952. transformedPosition: Vector3;
  8953. /**
  8954. * The transformed direction. Direction of the light in world space taking parenting in account.
  8955. */
  8956. transformedDirection: Vector3;
  8957. /**
  8958. * The friendly name of the light in the scene.
  8959. */
  8960. name: string;
  8961. /**
  8962. * Defines the shadow projection clipping minimum z value.
  8963. */
  8964. shadowMinZ: number;
  8965. /**
  8966. * Defines the shadow projection clipping maximum z value.
  8967. */
  8968. shadowMaxZ: number;
  8969. /**
  8970. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8971. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8972. */
  8973. computeTransformedInformation(): boolean;
  8974. /**
  8975. * Gets the scene the light belongs to.
  8976. * @returns The scene
  8977. */
  8978. getScene(): Scene;
  8979. /**
  8980. * Callback defining a custom Projection Matrix Builder.
  8981. * This can be used to override the default projection matrix computation.
  8982. */
  8983. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8984. /**
  8985. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8986. * @param matrix The materix to updated with the projection information
  8987. * @param viewMatrix The transform matrix of the light
  8988. * @param renderList The list of mesh to render in the map
  8989. * @returns The current light
  8990. */
  8991. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8992. /**
  8993. * Gets the current depth scale used in ESM.
  8994. * @returns The scale
  8995. */
  8996. getDepthScale(): number;
  8997. /**
  8998. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8999. * @returns true if a cube texture needs to be use
  9000. */
  9001. needCube(): boolean;
  9002. /**
  9003. * Detects if the projection matrix requires to be recomputed this frame.
  9004. * @returns true if it requires to be recomputed otherwise, false.
  9005. */
  9006. needProjectionMatrixCompute(): boolean;
  9007. /**
  9008. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9009. */
  9010. forceProjectionMatrixCompute(): void;
  9011. /**
  9012. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9013. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9014. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9015. */
  9016. getShadowDirection(faceIndex?: number): Vector3;
  9017. /**
  9018. * Gets the minZ used for shadow according to both the scene and the light.
  9019. * @param activeCamera The camera we are returning the min for
  9020. * @returns the depth min z
  9021. */
  9022. getDepthMinZ(activeCamera: Camera): number;
  9023. /**
  9024. * Gets the maxZ used for shadow according to both the scene and the light.
  9025. * @param activeCamera The camera we are returning the max for
  9026. * @returns the depth max z
  9027. */
  9028. getDepthMaxZ(activeCamera: Camera): number;
  9029. }
  9030. /**
  9031. * Base implementation IShadowLight
  9032. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9033. */
  9034. export abstract class ShadowLight extends Light implements IShadowLight {
  9035. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9036. protected _position: Vector3;
  9037. protected _setPosition(value: Vector3): void;
  9038. /**
  9039. * Sets the position the shadow will be casted from. Also use as the light position for both
  9040. * point and spot lights.
  9041. */
  9042. /**
  9043. * Sets the position the shadow will be casted from. Also use as the light position for both
  9044. * point and spot lights.
  9045. */
  9046. position: Vector3;
  9047. protected _direction: Vector3;
  9048. protected _setDirection(value: Vector3): void;
  9049. /**
  9050. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9051. * Also use as the light direction on spot and directional lights.
  9052. */
  9053. /**
  9054. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9055. * Also use as the light direction on spot and directional lights.
  9056. */
  9057. direction: Vector3;
  9058. private _shadowMinZ;
  9059. /**
  9060. * Gets the shadow projection clipping minimum z value.
  9061. */
  9062. /**
  9063. * Sets the shadow projection clipping minimum z value.
  9064. */
  9065. shadowMinZ: number;
  9066. private _shadowMaxZ;
  9067. /**
  9068. * Sets the shadow projection clipping maximum z value.
  9069. */
  9070. /**
  9071. * Gets the shadow projection clipping maximum z value.
  9072. */
  9073. shadowMaxZ: number;
  9074. /**
  9075. * Callback defining a custom Projection Matrix Builder.
  9076. * This can be used to override the default projection matrix computation.
  9077. */
  9078. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9079. /**
  9080. * The transformed position. Position of the light in world space taking parenting in account.
  9081. */
  9082. transformedPosition: Vector3;
  9083. /**
  9084. * The transformed direction. Direction of the light in world space taking parenting in account.
  9085. */
  9086. transformedDirection: Vector3;
  9087. private _needProjectionMatrixCompute;
  9088. /**
  9089. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9090. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9091. */
  9092. computeTransformedInformation(): boolean;
  9093. /**
  9094. * Return the depth scale used for the shadow map.
  9095. * @returns the depth scale.
  9096. */
  9097. getDepthScale(): number;
  9098. /**
  9099. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9100. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9101. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9102. */
  9103. getShadowDirection(faceIndex?: number): Vector3;
  9104. /**
  9105. * Returns the ShadowLight absolute position in the World.
  9106. * @returns the position vector in world space
  9107. */
  9108. getAbsolutePosition(): Vector3;
  9109. /**
  9110. * Sets the ShadowLight direction toward the passed target.
  9111. * @param target The point to target in local space
  9112. * @returns the updated ShadowLight direction
  9113. */
  9114. setDirectionToTarget(target: Vector3): Vector3;
  9115. /**
  9116. * Returns the light rotation in euler definition.
  9117. * @returns the x y z rotation in local space.
  9118. */
  9119. getRotation(): Vector3;
  9120. /**
  9121. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9122. * @returns true if a cube texture needs to be use
  9123. */
  9124. needCube(): boolean;
  9125. /**
  9126. * Detects if the projection matrix requires to be recomputed this frame.
  9127. * @returns true if it requires to be recomputed otherwise, false.
  9128. */
  9129. needProjectionMatrixCompute(): boolean;
  9130. /**
  9131. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9132. */
  9133. forceProjectionMatrixCompute(): void;
  9134. /** @hidden */ initCache(): void;
  9135. /** @hidden */ isSynchronized(): boolean;
  9136. /**
  9137. * Computes the world matrix of the node
  9138. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9139. * @returns the world matrix
  9140. */
  9141. computeWorldMatrix(force?: boolean): Matrix;
  9142. /**
  9143. * Gets the minZ used for shadow according to both the scene and the light.
  9144. * @param activeCamera The camera we are returning the min for
  9145. * @returns the depth min z
  9146. */
  9147. getDepthMinZ(activeCamera: Camera): number;
  9148. /**
  9149. * Gets the maxZ used for shadow according to both the scene and the light.
  9150. * @param activeCamera The camera we are returning the max for
  9151. * @returns the depth max z
  9152. */
  9153. getDepthMaxZ(activeCamera: Camera): number;
  9154. /**
  9155. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9156. * @param matrix The materix to updated with the projection information
  9157. * @param viewMatrix The transform matrix of the light
  9158. * @param renderList The list of mesh to render in the map
  9159. * @returns The current light
  9160. */
  9161. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9162. }
  9163. }
  9164. declare module BABYLON {
  9165. /**
  9166. * "Static Class" containing the most commonly used helper while dealing with material for
  9167. * rendering purpose.
  9168. *
  9169. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9170. *
  9171. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9172. */
  9173. export class MaterialHelper {
  9174. /**
  9175. * Bind the current view position to an effect.
  9176. * @param effect The effect to be bound
  9177. * @param scene The scene the eyes position is used from
  9178. */
  9179. static BindEyePosition(effect: Effect, scene: Scene): void;
  9180. /**
  9181. * Helps preparing the defines values about the UVs in used in the effect.
  9182. * UVs are shared as much as we can accross channels in the shaders.
  9183. * @param texture The texture we are preparing the UVs for
  9184. * @param defines The defines to update
  9185. * @param key The channel key "diffuse", "specular"... used in the shader
  9186. */
  9187. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9188. /**
  9189. * Binds a texture matrix value to its corrsponding uniform
  9190. * @param texture The texture to bind the matrix for
  9191. * @param uniformBuffer The uniform buffer receivin the data
  9192. * @param key The channel key "diffuse", "specular"... used in the shader
  9193. */
  9194. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9195. /**
  9196. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9197. * @param mesh defines the current mesh
  9198. * @param scene defines the current scene
  9199. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9200. * @param pointsCloud defines if point cloud rendering has to be turned on
  9201. * @param fogEnabled defines if fog has to be turned on
  9202. * @param alphaTest defines if alpha testing has to be turned on
  9203. * @param defines defines the current list of defines
  9204. */
  9205. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9206. /**
  9207. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9208. * @param scene defines the current scene
  9209. * @param engine defines the current engine
  9210. * @param defines specifies the list of active defines
  9211. * @param useInstances defines if instances have to be turned on
  9212. * @param useClipPlane defines if clip plane have to be turned on
  9213. */
  9214. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9215. /**
  9216. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9217. * @param mesh The mesh containing the geometry data we will draw
  9218. * @param defines The defines to update
  9219. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9220. * @param useBones Precise whether bones should be used or not (override mesh info)
  9221. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9222. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9223. * @returns false if defines are considered not dirty and have not been checked
  9224. */
  9225. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9226. /**
  9227. * Prepares the defines related to multiview
  9228. * @param scene The scene we are intending to draw
  9229. * @param defines The defines to update
  9230. */
  9231. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9232. /**
  9233. * Prepares the defines related to the light information passed in parameter
  9234. * @param scene The scene we are intending to draw
  9235. * @param mesh The mesh the effect is compiling for
  9236. * @param defines The defines to update
  9237. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9238. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9239. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9240. * @returns true if normals will be required for the rest of the effect
  9241. */
  9242. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9243. /**
  9244. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9245. * that won t be acctive due to defines being turned off.
  9246. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9247. * @param samplersList The samplers list
  9248. * @param defines The defines helping in the list generation
  9249. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9250. */
  9251. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9252. /**
  9253. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9254. * @param defines The defines to update while falling back
  9255. * @param fallbacks The authorized effect fallbacks
  9256. * @param maxSimultaneousLights The maximum number of lights allowed
  9257. * @param rank the current rank of the Effect
  9258. * @returns The newly affected rank
  9259. */
  9260. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9261. /**
  9262. * Prepares the list of attributes required for morph targets according to the effect defines.
  9263. * @param attribs The current list of supported attribs
  9264. * @param mesh The mesh to prepare the morph targets attributes for
  9265. * @param defines The current Defines of the effect
  9266. */
  9267. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9268. /**
  9269. * Prepares the list of attributes required for bones according to the effect defines.
  9270. * @param attribs The current list of supported attribs
  9271. * @param mesh The mesh to prepare the bones attributes for
  9272. * @param defines The current Defines of the effect
  9273. * @param fallbacks The current efffect fallback strategy
  9274. */
  9275. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9276. /**
  9277. * Prepares the list of attributes required for instances according to the effect defines.
  9278. * @param attribs The current list of supported attribs
  9279. * @param defines The current Defines of the effect
  9280. */
  9281. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9282. /**
  9283. * Binds the light shadow information to the effect for the given mesh.
  9284. * @param light The light containing the generator
  9285. * @param scene The scene the lights belongs to
  9286. * @param mesh The mesh we are binding the information to render
  9287. * @param lightIndex The light index in the effect used to render the mesh
  9288. * @param effect The effect we are binding the data to
  9289. */
  9290. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9291. /**
  9292. * Binds the light information to the effect.
  9293. * @param light The light containing the generator
  9294. * @param effect The effect we are binding the data to
  9295. * @param lightIndex The light index in the effect used to render
  9296. */
  9297. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9298. /**
  9299. * Binds the lights information from the scene to the effect for the given mesh.
  9300. * @param scene The scene the lights belongs to
  9301. * @param mesh The mesh we are binding the information to render
  9302. * @param effect The effect we are binding the data to
  9303. * @param defines The generated defines for the effect
  9304. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9305. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9306. */
  9307. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9308. private static _tempFogColor;
  9309. /**
  9310. * Binds the fog information from the scene to the effect for the given mesh.
  9311. * @param scene The scene the lights belongs to
  9312. * @param mesh The mesh we are binding the information to render
  9313. * @param effect The effect we are binding the data to
  9314. * @param linearSpace Defines if the fog effect is applied in linear space
  9315. */
  9316. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9317. /**
  9318. * Binds the bones information from the mesh to the effect.
  9319. * @param mesh The mesh we are binding the information to render
  9320. * @param effect The effect we are binding the data to
  9321. */
  9322. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9323. /**
  9324. * Binds the morph targets information from the mesh to the effect.
  9325. * @param abstractMesh The mesh we are binding the information to render
  9326. * @param effect The effect we are binding the data to
  9327. */
  9328. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9329. /**
  9330. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9331. * @param defines The generated defines used in the effect
  9332. * @param effect The effect we are binding the data to
  9333. * @param scene The scene we are willing to render with logarithmic scale for
  9334. */
  9335. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9336. /**
  9337. * Binds the clip plane information from the scene to the effect.
  9338. * @param scene The scene the clip plane information are extracted from
  9339. * @param effect The effect we are binding the data to
  9340. */
  9341. static BindClipPlane(effect: Effect, scene: Scene): void;
  9342. }
  9343. }
  9344. declare module BABYLON {
  9345. /** @hidden */
  9346. export var kernelBlurVaryingDeclaration: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module BABYLON {
  9352. /** @hidden */
  9353. export var kernelBlurFragment: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module BABYLON {
  9359. /** @hidden */
  9360. export var kernelBlurFragment2: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module BABYLON {
  9366. /** @hidden */
  9367. export var kernelBlurPixelShader: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module BABYLON {
  9373. /** @hidden */
  9374. export var kernelBlurVertex: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module BABYLON {
  9380. /** @hidden */
  9381. export var kernelBlurVertexShader: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module BABYLON {
  9387. /**
  9388. * The Blur Post Process which blurs an image based on a kernel and direction.
  9389. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9390. */
  9391. export class BlurPostProcess extends PostProcess {
  9392. /** The direction in which to blur the image. */
  9393. direction: Vector2;
  9394. private blockCompilation;
  9395. protected _kernel: number;
  9396. protected _idealKernel: number;
  9397. protected _packedFloat: boolean;
  9398. private _staticDefines;
  9399. /**
  9400. * Sets the length in pixels of the blur sample region
  9401. */
  9402. /**
  9403. * Gets the length in pixels of the blur sample region
  9404. */
  9405. kernel: number;
  9406. /**
  9407. * Sets wether or not the blur needs to unpack/repack floats
  9408. */
  9409. /**
  9410. * Gets wether or not the blur is unpacking/repacking floats
  9411. */
  9412. packedFloat: boolean;
  9413. /**
  9414. * Creates a new instance BlurPostProcess
  9415. * @param name The name of the effect.
  9416. * @param direction The direction in which to blur the image.
  9417. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  9418. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9419. * @param camera The camera to apply the render pass to.
  9420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9421. * @param engine The engine which the post process will be applied. (default: current engine)
  9422. * @param reusable If the post process can be reused on the same frame. (default: false)
  9423. * @param textureType Type of textures used when performing the post process. (default: 0)
  9424. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  9425. */
  9426. constructor(name: string,
  9427. /** The direction in which to blur the image. */
  9428. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9429. /**
  9430. * Updates the effect with the current post process compile time values and recompiles the shader.
  9431. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9432. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9433. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9434. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  9435. * @param onCompiled Called when the shader has been compiled.
  9436. * @param onError Called if there is an error when compiling a shader.
  9437. */
  9438. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9439. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9440. /**
  9441. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9442. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9443. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9444. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9445. * The gaps between physical kernels are compensated for in the weighting of the samples
  9446. * @param idealKernel Ideal blur kernel.
  9447. * @return Nearest best kernel.
  9448. */
  9449. protected _nearestBestKernel(idealKernel: number): number;
  9450. /**
  9451. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9452. * @param x The point on the Gaussian distribution to sample.
  9453. * @return the value of the Gaussian function at x.
  9454. */
  9455. protected _gaussianWeight(x: number): number;
  9456. /**
  9457. * Generates a string that can be used as a floating point number in GLSL.
  9458. * @param x Value to print.
  9459. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9460. * @return GLSL float string.
  9461. */
  9462. protected _glslFloat(x: number, decimalFigures?: number): string;
  9463. }
  9464. }
  9465. declare module BABYLON {
  9466. /** @hidden */
  9467. export var shadowMapPixelShader: {
  9468. name: string;
  9469. shader: string;
  9470. };
  9471. }
  9472. declare module BABYLON {
  9473. /** @hidden */
  9474. export var bonesDeclaration: {
  9475. name: string;
  9476. shader: string;
  9477. };
  9478. }
  9479. declare module BABYLON {
  9480. /** @hidden */
  9481. export var morphTargetsVertexGlobalDeclaration: {
  9482. name: string;
  9483. shader: string;
  9484. };
  9485. }
  9486. declare module BABYLON {
  9487. /** @hidden */
  9488. export var morphTargetsVertexDeclaration: {
  9489. name: string;
  9490. shader: string;
  9491. };
  9492. }
  9493. declare module BABYLON {
  9494. /** @hidden */
  9495. export var instancesDeclaration: {
  9496. name: string;
  9497. shader: string;
  9498. };
  9499. }
  9500. declare module BABYLON {
  9501. /** @hidden */
  9502. export var helperFunctions: {
  9503. name: string;
  9504. shader: string;
  9505. };
  9506. }
  9507. declare module BABYLON {
  9508. /** @hidden */
  9509. export var morphTargetsVertex: {
  9510. name: string;
  9511. shader: string;
  9512. };
  9513. }
  9514. declare module BABYLON {
  9515. /** @hidden */
  9516. export var instancesVertex: {
  9517. name: string;
  9518. shader: string;
  9519. };
  9520. }
  9521. declare module BABYLON {
  9522. /** @hidden */
  9523. export var bonesVertex: {
  9524. name: string;
  9525. shader: string;
  9526. };
  9527. }
  9528. declare module BABYLON {
  9529. /** @hidden */
  9530. export var shadowMapVertexShader: {
  9531. name: string;
  9532. shader: string;
  9533. };
  9534. }
  9535. declare module BABYLON {
  9536. /** @hidden */
  9537. export var depthBoxBlurPixelShader: {
  9538. name: string;
  9539. shader: string;
  9540. };
  9541. }
  9542. declare module BABYLON {
  9543. /**
  9544. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9545. */
  9546. export interface ICustomShaderOptions {
  9547. /**
  9548. * Gets or sets the custom shader name to use
  9549. */
  9550. shaderName: string;
  9551. /**
  9552. * The list of attribute names used in the shader
  9553. */
  9554. attributes?: string[];
  9555. /**
  9556. * The list of unifrom names used in the shader
  9557. */
  9558. uniforms?: string[];
  9559. /**
  9560. * The list of sampler names used in the shader
  9561. */
  9562. samplers?: string[];
  9563. /**
  9564. * The list of defines used in the shader
  9565. */
  9566. defines?: string[];
  9567. }
  9568. /**
  9569. * Interface to implement to create a shadow generator compatible with BJS.
  9570. */
  9571. export interface IShadowGenerator {
  9572. /**
  9573. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9574. * @returns The render target texture if present otherwise, null
  9575. */
  9576. getShadowMap(): Nullable<RenderTargetTexture>;
  9577. /**
  9578. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9579. * @returns The render target texture if the shadow map is present otherwise, null
  9580. */
  9581. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9582. /**
  9583. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9584. * @param subMesh The submesh we want to render in the shadow map
  9585. * @param useInstances Defines wether will draw in the map using instances
  9586. * @returns true if ready otherwise, false
  9587. */
  9588. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9589. /**
  9590. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9591. * @param defines Defines of the material we want to update
  9592. * @param lightIndex Index of the light in the enabled light list of the material
  9593. */
  9594. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9595. /**
  9596. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9597. * defined in the generator but impacting the effect).
  9598. * It implies the unifroms available on the materials are the standard BJS ones.
  9599. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9600. * @param effect The effect we are binfing the information for
  9601. */
  9602. bindShadowLight(lightIndex: string, effect: Effect): void;
  9603. /**
  9604. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9605. * (eq to shadow prjection matrix * light transform matrix)
  9606. * @returns The transform matrix used to create the shadow map
  9607. */
  9608. getTransformMatrix(): Matrix;
  9609. /**
  9610. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9611. * Cube and 2D textures for instance.
  9612. */
  9613. recreateShadowMap(): void;
  9614. /**
  9615. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9616. * @param onCompiled Callback triggered at the and of the effects compilation
  9617. * @param options Sets of optional options forcing the compilation with different modes
  9618. */
  9619. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9620. useInstances: boolean;
  9621. }>): void;
  9622. /**
  9623. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9624. * @param options Sets of optional options forcing the compilation with different modes
  9625. * @returns A promise that resolves when the compilation completes
  9626. */
  9627. forceCompilationAsync(options?: Partial<{
  9628. useInstances: boolean;
  9629. }>): Promise<void>;
  9630. /**
  9631. * Serializes the shadow generator setup to a json object.
  9632. * @returns The serialized JSON object
  9633. */
  9634. serialize(): any;
  9635. /**
  9636. * Disposes the Shadow map and related Textures and effects.
  9637. */
  9638. dispose(): void;
  9639. }
  9640. /**
  9641. * Default implementation IShadowGenerator.
  9642. * This is the main object responsible of generating shadows in the framework.
  9643. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9644. */
  9645. export class ShadowGenerator implements IShadowGenerator {
  9646. /**
  9647. * Shadow generator mode None: no filtering applied.
  9648. */
  9649. static readonly FILTER_NONE: number;
  9650. /**
  9651. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9652. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9653. */
  9654. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9655. /**
  9656. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9657. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9658. */
  9659. static readonly FILTER_POISSONSAMPLING: number;
  9660. /**
  9661. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9662. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9663. */
  9664. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9665. /**
  9666. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9667. * edge artifacts on steep falloff.
  9668. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9669. */
  9670. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9671. /**
  9672. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9673. * edge artifacts on steep falloff.
  9674. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9675. */
  9676. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9677. /**
  9678. * Shadow generator mode PCF: Percentage Closer Filtering
  9679. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9680. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9681. */
  9682. static readonly FILTER_PCF: number;
  9683. /**
  9684. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9685. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9686. * Contact Hardening
  9687. */
  9688. static readonly FILTER_PCSS: number;
  9689. /**
  9690. * Reserved for PCF and PCSS
  9691. * Highest Quality.
  9692. *
  9693. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9694. *
  9695. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9696. */
  9697. static readonly QUALITY_HIGH: number;
  9698. /**
  9699. * Reserved for PCF and PCSS
  9700. * Good tradeoff for quality/perf cross devices
  9701. *
  9702. * Execute PCF on a 3*3 kernel.
  9703. *
  9704. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9705. */
  9706. static readonly QUALITY_MEDIUM: number;
  9707. /**
  9708. * Reserved for PCF and PCSS
  9709. * The lowest quality but the fastest.
  9710. *
  9711. * Execute PCF on a 1*1 kernel.
  9712. *
  9713. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9714. */
  9715. static readonly QUALITY_LOW: number;
  9716. /** Gets or sets the custom shader name to use */
  9717. customShaderOptions: ICustomShaderOptions;
  9718. /**
  9719. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9720. */
  9721. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9722. /**
  9723. * Observable triggered before a mesh is rendered in the shadow map.
  9724. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9725. */
  9726. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9727. private _bias;
  9728. /**
  9729. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9730. */
  9731. /**
  9732. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9733. */
  9734. bias: number;
  9735. private _normalBias;
  9736. /**
  9737. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9738. */
  9739. /**
  9740. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9741. */
  9742. normalBias: number;
  9743. private _blurBoxOffset;
  9744. /**
  9745. * Gets the blur box offset: offset applied during the blur pass.
  9746. * Only useful if useKernelBlur = false
  9747. */
  9748. /**
  9749. * Sets the blur box offset: offset applied during the blur pass.
  9750. * Only useful if useKernelBlur = false
  9751. */
  9752. blurBoxOffset: number;
  9753. private _blurScale;
  9754. /**
  9755. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9756. * 2 means half of the size.
  9757. */
  9758. /**
  9759. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9760. * 2 means half of the size.
  9761. */
  9762. blurScale: number;
  9763. private _blurKernel;
  9764. /**
  9765. * Gets the blur kernel: kernel size of the blur pass.
  9766. * Only useful if useKernelBlur = true
  9767. */
  9768. /**
  9769. * Sets the blur kernel: kernel size of the blur pass.
  9770. * Only useful if useKernelBlur = true
  9771. */
  9772. blurKernel: number;
  9773. private _useKernelBlur;
  9774. /**
  9775. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9776. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9777. */
  9778. /**
  9779. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9780. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9781. */
  9782. useKernelBlur: boolean;
  9783. private _depthScale;
  9784. /**
  9785. * Gets the depth scale used in ESM mode.
  9786. */
  9787. /**
  9788. * Sets the depth scale used in ESM mode.
  9789. * This can override the scale stored on the light.
  9790. */
  9791. depthScale: number;
  9792. private _filter;
  9793. /**
  9794. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9795. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9796. */
  9797. /**
  9798. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9799. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9800. */
  9801. filter: number;
  9802. /**
  9803. * Gets if the current filter is set to Poisson Sampling.
  9804. */
  9805. /**
  9806. * Sets the current filter to Poisson Sampling.
  9807. */
  9808. usePoissonSampling: boolean;
  9809. /**
  9810. * Gets if the current filter is set to ESM.
  9811. */
  9812. /**
  9813. * Sets the current filter is to ESM.
  9814. */
  9815. useExponentialShadowMap: boolean;
  9816. /**
  9817. * Gets if the current filter is set to filtered ESM.
  9818. */
  9819. /**
  9820. * Gets if the current filter is set to filtered ESM.
  9821. */
  9822. useBlurExponentialShadowMap: boolean;
  9823. /**
  9824. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9825. * exponential to prevent steep falloff artifacts).
  9826. */
  9827. /**
  9828. * Sets the current filter to "close ESM" (using the inverse of the
  9829. * exponential to prevent steep falloff artifacts).
  9830. */
  9831. useCloseExponentialShadowMap: boolean;
  9832. /**
  9833. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9834. * exponential to prevent steep falloff artifacts).
  9835. */
  9836. /**
  9837. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9838. * exponential to prevent steep falloff artifacts).
  9839. */
  9840. useBlurCloseExponentialShadowMap: boolean;
  9841. /**
  9842. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9843. */
  9844. /**
  9845. * Sets the current filter to "PCF" (percentage closer filtering).
  9846. */
  9847. usePercentageCloserFiltering: boolean;
  9848. private _filteringQuality;
  9849. /**
  9850. * Gets the PCF or PCSS Quality.
  9851. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9852. */
  9853. /**
  9854. * Sets the PCF or PCSS Quality.
  9855. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9856. */
  9857. filteringQuality: number;
  9858. /**
  9859. * Gets if the current filter is set to "PCSS" (contact hardening).
  9860. */
  9861. /**
  9862. * Sets the current filter to "PCSS" (contact hardening).
  9863. */
  9864. useContactHardeningShadow: boolean;
  9865. private _contactHardeningLightSizeUVRatio;
  9866. /**
  9867. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9868. * Using a ratio helps keeping shape stability independently of the map size.
  9869. *
  9870. * It does not account for the light projection as it was having too much
  9871. * instability during the light setup or during light position changes.
  9872. *
  9873. * Only valid if useContactHardeningShadow is true.
  9874. */
  9875. /**
  9876. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9877. * Using a ratio helps keeping shape stability independently of the map size.
  9878. *
  9879. * It does not account for the light projection as it was having too much
  9880. * instability during the light setup or during light position changes.
  9881. *
  9882. * Only valid if useContactHardeningShadow is true.
  9883. */
  9884. contactHardeningLightSizeUVRatio: number;
  9885. private _darkness;
  9886. /**
  9887. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9888. * 0 means strongest and 1 would means no shadow.
  9889. * @returns the darkness.
  9890. */
  9891. getDarkness(): number;
  9892. /**
  9893. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9894. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9895. * @returns the shadow generator allowing fluent coding.
  9896. */
  9897. setDarkness(darkness: number): ShadowGenerator;
  9898. private _transparencyShadow;
  9899. /**
  9900. * Sets the ability to have transparent shadow (boolean).
  9901. * @param transparent True if transparent else False
  9902. * @returns the shadow generator allowing fluent coding
  9903. */
  9904. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9905. private _shadowMap;
  9906. private _shadowMap2;
  9907. /**
  9908. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9909. * @returns The render target texture if present otherwise, null
  9910. */
  9911. getShadowMap(): Nullable<RenderTargetTexture>;
  9912. /**
  9913. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9914. * @returns The render target texture if the shadow map is present otherwise, null
  9915. */
  9916. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9917. /**
  9918. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9919. * @param mesh Mesh to add
  9920. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9921. * @returns the Shadow Generator itself
  9922. */
  9923. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9924. /**
  9925. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9926. * @param mesh Mesh to remove
  9927. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9928. * @returns the Shadow Generator itself
  9929. */
  9930. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9931. /**
  9932. * Controls the extent to which the shadows fade out at the edge of the frustum
  9933. * Used only by directionals and spots
  9934. */
  9935. frustumEdgeFalloff: number;
  9936. private _light;
  9937. /**
  9938. * Returns the associated light object.
  9939. * @returns the light generating the shadow
  9940. */
  9941. getLight(): IShadowLight;
  9942. /**
  9943. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9944. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9945. * It might on the other hand introduce peter panning.
  9946. */
  9947. forceBackFacesOnly: boolean;
  9948. private _scene;
  9949. private _lightDirection;
  9950. private _effect;
  9951. private _viewMatrix;
  9952. private _projectionMatrix;
  9953. private _transformMatrix;
  9954. private _cachedPosition;
  9955. private _cachedDirection;
  9956. private _cachedDefines;
  9957. private _currentRenderID;
  9958. private _boxBlurPostprocess;
  9959. private _kernelBlurXPostprocess;
  9960. private _kernelBlurYPostprocess;
  9961. private _blurPostProcesses;
  9962. private _mapSize;
  9963. private _currentFaceIndex;
  9964. private _currentFaceIndexCache;
  9965. private _textureType;
  9966. private _defaultTextureMatrix;
  9967. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9968. /**
  9969. * Creates a ShadowGenerator object.
  9970. * A ShadowGenerator is the required tool to use the shadows.
  9971. * Each light casting shadows needs to use its own ShadowGenerator.
  9972. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9973. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9974. * @param light The light object generating the shadows.
  9975. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9976. */
  9977. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9978. private _initializeGenerator;
  9979. private _initializeShadowMap;
  9980. private _initializeBlurRTTAndPostProcesses;
  9981. private _renderForShadowMap;
  9982. private _renderSubMeshForShadowMap;
  9983. private _applyFilterValues;
  9984. /**
  9985. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9986. * @param onCompiled Callback triggered at the and of the effects compilation
  9987. * @param options Sets of optional options forcing the compilation with different modes
  9988. */
  9989. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9990. useInstances: boolean;
  9991. }>): void;
  9992. /**
  9993. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9994. * @param options Sets of optional options forcing the compilation with different modes
  9995. * @returns A promise that resolves when the compilation completes
  9996. */
  9997. forceCompilationAsync(options?: Partial<{
  9998. useInstances: boolean;
  9999. }>): Promise<void>;
  10000. /**
  10001. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10002. * @param subMesh The submesh we want to render in the shadow map
  10003. * @param useInstances Defines wether will draw in the map using instances
  10004. * @returns true if ready otherwise, false
  10005. */
  10006. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10007. /**
  10008. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10009. * @param defines Defines of the material we want to update
  10010. * @param lightIndex Index of the light in the enabled light list of the material
  10011. */
  10012. prepareDefines(defines: any, lightIndex: number): void;
  10013. /**
  10014. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10015. * defined in the generator but impacting the effect).
  10016. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10017. * @param effect The effect we are binfing the information for
  10018. */
  10019. bindShadowLight(lightIndex: string, effect: Effect): void;
  10020. /**
  10021. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10022. * (eq to shadow prjection matrix * light transform matrix)
  10023. * @returns The transform matrix used to create the shadow map
  10024. */
  10025. getTransformMatrix(): Matrix;
  10026. /**
  10027. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10028. * Cube and 2D textures for instance.
  10029. */
  10030. recreateShadowMap(): void;
  10031. private _disposeBlurPostProcesses;
  10032. private _disposeRTTandPostProcesses;
  10033. /**
  10034. * Disposes the ShadowGenerator.
  10035. * Returns nothing.
  10036. */
  10037. dispose(): void;
  10038. /**
  10039. * Serializes the shadow generator setup to a json object.
  10040. * @returns The serialized JSON object
  10041. */
  10042. serialize(): any;
  10043. /**
  10044. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10045. * @param parsedShadowGenerator The JSON object to parse
  10046. * @param scene The scene to create the shadow map for
  10047. * @returns The parsed shadow generator
  10048. */
  10049. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10050. }
  10051. }
  10052. declare module BABYLON {
  10053. /**
  10054. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10055. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10056. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  10057. */
  10058. export abstract class Light extends Node {
  10059. /**
  10060. * Falloff Default: light is falling off following the material specification:
  10061. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10062. */
  10063. static readonly FALLOFF_DEFAULT: number;
  10064. /**
  10065. * Falloff Physical: light is falling off following the inverse squared distance law.
  10066. */
  10067. static readonly FALLOFF_PHYSICAL: number;
  10068. /**
  10069. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10070. * to enhance interoperability with other engines.
  10071. */
  10072. static readonly FALLOFF_GLTF: number;
  10073. /**
  10074. * Falloff Standard: light is falling off like in the standard material
  10075. * to enhance interoperability with other materials.
  10076. */
  10077. static readonly FALLOFF_STANDARD: number;
  10078. /**
  10079. * If every light affecting the material is in this lightmapMode,
  10080. * material.lightmapTexture adds or multiplies
  10081. * (depends on material.useLightmapAsShadowmap)
  10082. * after every other light calculations.
  10083. */
  10084. static readonly LIGHTMAP_DEFAULT: number;
  10085. /**
  10086. * material.lightmapTexture as only diffuse lighting from this light
  10087. * adds only specular lighting from this light
  10088. * adds dynamic shadows
  10089. */
  10090. static readonly LIGHTMAP_SPECULAR: number;
  10091. /**
  10092. * material.lightmapTexture as only lighting
  10093. * no light calculation from this light
  10094. * only adds dynamic shadows from this light
  10095. */
  10096. static readonly LIGHTMAP_SHADOWSONLY: number;
  10097. /**
  10098. * Each light type uses the default quantity according to its type:
  10099. * point/spot lights use luminous intensity
  10100. * directional lights use illuminance
  10101. */
  10102. static readonly INTENSITYMODE_AUTOMATIC: number;
  10103. /**
  10104. * lumen (lm)
  10105. */
  10106. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10107. /**
  10108. * candela (lm/sr)
  10109. */
  10110. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10111. /**
  10112. * lux (lm/m^2)
  10113. */
  10114. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10115. /**
  10116. * nit (cd/m^2)
  10117. */
  10118. static readonly INTENSITYMODE_LUMINANCE: number;
  10119. /**
  10120. * Light type const id of the point light.
  10121. */
  10122. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10123. /**
  10124. * Light type const id of the directional light.
  10125. */
  10126. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10127. /**
  10128. * Light type const id of the spot light.
  10129. */
  10130. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10131. /**
  10132. * Light type const id of the hemispheric light.
  10133. */
  10134. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10135. /**
  10136. * Diffuse gives the basic color to an object.
  10137. */
  10138. diffuse: Color3;
  10139. /**
  10140. * Specular produces a highlight color on an object.
  10141. * Note: This is note affecting PBR materials.
  10142. */
  10143. specular: Color3;
  10144. /**
  10145. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10146. * falling off base on range or angle.
  10147. * This can be set to any values in Light.FALLOFF_x.
  10148. *
  10149. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10150. * other types of materials.
  10151. */
  10152. falloffType: number;
  10153. /**
  10154. * Strength of the light.
  10155. * Note: By default it is define in the framework own unit.
  10156. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10157. */
  10158. intensity: number;
  10159. private _range;
  10160. protected _inverseSquaredRange: number;
  10161. /**
  10162. * Defines how far from the source the light is impacting in scene units.
  10163. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10164. */
  10165. /**
  10166. * Defines how far from the source the light is impacting in scene units.
  10167. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10168. */
  10169. range: number;
  10170. /**
  10171. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10172. * of light.
  10173. */
  10174. private _photometricScale;
  10175. private _intensityMode;
  10176. /**
  10177. * Gets the photometric scale used to interpret the intensity.
  10178. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10179. */
  10180. /**
  10181. * Sets the photometric scale used to interpret the intensity.
  10182. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10183. */
  10184. intensityMode: number;
  10185. private _radius;
  10186. /**
  10187. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10188. */
  10189. /**
  10190. * sets the light radius used by PBR Materials to simulate soft area lights.
  10191. */
  10192. radius: number;
  10193. private _renderPriority;
  10194. /**
  10195. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10196. * exceeding the number allowed of the materials.
  10197. */
  10198. renderPriority: number;
  10199. private _shadowEnabled;
  10200. /**
  10201. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10202. * the current shadow generator.
  10203. */
  10204. /**
  10205. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10206. * the current shadow generator.
  10207. */
  10208. shadowEnabled: boolean;
  10209. private _includedOnlyMeshes;
  10210. /**
  10211. * Gets the only meshes impacted by this light.
  10212. */
  10213. /**
  10214. * Sets the only meshes impacted by this light.
  10215. */
  10216. includedOnlyMeshes: AbstractMesh[];
  10217. private _excludedMeshes;
  10218. /**
  10219. * Gets the meshes not impacted by this light.
  10220. */
  10221. /**
  10222. * Sets the meshes not impacted by this light.
  10223. */
  10224. excludedMeshes: AbstractMesh[];
  10225. private _excludeWithLayerMask;
  10226. /**
  10227. * Gets the layer id use to find what meshes are not impacted by the light.
  10228. * Inactive if 0
  10229. */
  10230. /**
  10231. * Sets the layer id use to find what meshes are not impacted by the light.
  10232. * Inactive if 0
  10233. */
  10234. excludeWithLayerMask: number;
  10235. private _includeOnlyWithLayerMask;
  10236. /**
  10237. * Gets the layer id use to find what meshes are impacted by the light.
  10238. * Inactive if 0
  10239. */
  10240. /**
  10241. * Sets the layer id use to find what meshes are impacted by the light.
  10242. * Inactive if 0
  10243. */
  10244. includeOnlyWithLayerMask: number;
  10245. private _lightmapMode;
  10246. /**
  10247. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10248. */
  10249. /**
  10250. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10251. */
  10252. lightmapMode: number;
  10253. /**
  10254. * Shadow generator associted to the light.
  10255. * @hidden Internal use only.
  10256. */ shadowGenerator: Nullable<IShadowGenerator>;
  10257. /**
  10258. * @hidden Internal use only.
  10259. */ excludedMeshesIds: string[];
  10260. /**
  10261. * @hidden Internal use only.
  10262. */ includedOnlyMeshesIds: string[];
  10263. /**
  10264. * The current light unifom buffer.
  10265. * @hidden Internal use only.
  10266. */ uniformBuffer: UniformBuffer;
  10267. /**
  10268. * Creates a Light object in the scene.
  10269. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10270. * @param name The firendly name of the light
  10271. * @param scene The scene the light belongs too
  10272. */
  10273. constructor(name: string, scene: Scene);
  10274. protected abstract _buildUniformLayout(): void;
  10275. /**
  10276. * Sets the passed Effect "effect" with the Light information.
  10277. * @param effect The effect to update
  10278. * @param lightIndex The index of the light in the effect to update
  10279. * @returns The light
  10280. */
  10281. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10282. /**
  10283. * Returns the string "Light".
  10284. * @returns the class name
  10285. */
  10286. getClassName(): string;
  10287. /** @hidden */ protected readonly _isLight: boolean;
  10288. /**
  10289. * Converts the light information to a readable string for debug purpose.
  10290. * @param fullDetails Supports for multiple levels of logging within scene loading
  10291. * @returns the human readable light info
  10292. */
  10293. toString(fullDetails?: boolean): string;
  10294. /** @hidden */
  10295. protected _syncParentEnabledState(): void;
  10296. /**
  10297. * Set the enabled state of this node.
  10298. * @param value - the new enabled state
  10299. */
  10300. setEnabled(value: boolean): void;
  10301. /**
  10302. * Returns the Light associated shadow generator if any.
  10303. * @return the associated shadow generator.
  10304. */
  10305. getShadowGenerator(): Nullable<IShadowGenerator>;
  10306. /**
  10307. * Returns a Vector3, the absolute light position in the World.
  10308. * @returns the world space position of the light
  10309. */
  10310. getAbsolutePosition(): Vector3;
  10311. /**
  10312. * Specifies if the light will affect the passed mesh.
  10313. * @param mesh The mesh to test against the light
  10314. * @return true the mesh is affected otherwise, false.
  10315. */
  10316. canAffectMesh(mesh: AbstractMesh): boolean;
  10317. /**
  10318. * Sort function to order lights for rendering.
  10319. * @param a First Light object to compare to second.
  10320. * @param b Second Light object to compare first.
  10321. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10322. */
  10323. static CompareLightsPriority(a: Light, b: Light): number;
  10324. /**
  10325. * Releases resources associated with this node.
  10326. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10327. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10328. */
  10329. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10330. /**
  10331. * Returns the light type ID (integer).
  10332. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10333. */
  10334. getTypeID(): number;
  10335. /**
  10336. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10337. * @returns the scaled intensity in intensity mode unit
  10338. */
  10339. getScaledIntensity(): number;
  10340. /**
  10341. * Returns a new Light object, named "name", from the current one.
  10342. * @param name The name of the cloned light
  10343. * @returns the new created light
  10344. */
  10345. clone(name: string): Nullable<Light>;
  10346. /**
  10347. * Serializes the current light into a Serialization object.
  10348. * @returns the serialized object.
  10349. */
  10350. serialize(): any;
  10351. /**
  10352. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10353. * This new light is named "name" and added to the passed scene.
  10354. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10355. * @param name The friendly name of the light
  10356. * @param scene The scene the new light will belong to
  10357. * @returns the constructor function
  10358. */
  10359. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10360. /**
  10361. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10362. * @param parsedLight The JSON representation of the light
  10363. * @param scene The scene to create the parsed light in
  10364. * @returns the created light after parsing
  10365. */
  10366. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10367. private _hookArrayForExcluded;
  10368. private _hookArrayForIncludedOnly;
  10369. private _resyncMeshes;
  10370. /**
  10371. * Forces the meshes to update their light related information in their rendering used effects
  10372. * @hidden Internal Use Only
  10373. */ markMeshesAsLightDirty(): void;
  10374. /**
  10375. * Recomputes the cached photometric scale if needed.
  10376. */
  10377. private _computePhotometricScale;
  10378. /**
  10379. * Returns the Photometric Scale according to the light type and intensity mode.
  10380. */
  10381. private _getPhotometricScale;
  10382. /**
  10383. * Reorder the light in the scene according to their defined priority.
  10384. * @hidden Internal Use Only
  10385. */ reorderLightsInScene(): void;
  10386. /**
  10387. * Prepares the list of defines specific to the light type.
  10388. * @param defines the list of defines
  10389. * @param lightIndex defines the index of the light for the effect
  10390. */
  10391. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10392. }
  10393. }
  10394. declare module BABYLON {
  10395. /**
  10396. * Interface used to define Action
  10397. */
  10398. export interface IAction {
  10399. /**
  10400. * Trigger for the action
  10401. */
  10402. trigger: number;
  10403. /** Options of the trigger */
  10404. triggerOptions: any;
  10405. /**
  10406. * Gets the trigger parameters
  10407. * @returns the trigger parameters
  10408. */
  10409. getTriggerParameter(): any;
  10410. /**
  10411. * Internal only - executes current action event
  10412. * @hidden
  10413. */ executeCurrent(evt?: ActionEvent): void;
  10414. /**
  10415. * Serialize placeholder for child classes
  10416. * @param parent of child
  10417. * @returns the serialized object
  10418. */
  10419. serialize(parent: any): any;
  10420. /**
  10421. * Internal only
  10422. * @hidden
  10423. */ prepare(): void;
  10424. /**
  10425. * Internal only - manager for action
  10426. * @hidden
  10427. */ actionManager: AbstractActionManager;
  10428. }
  10429. /**
  10430. * The action to be carried out following a trigger
  10431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10432. */
  10433. export class Action implements IAction {
  10434. /** the trigger, with or without parameters, for the action */
  10435. triggerOptions: any;
  10436. /**
  10437. * Trigger for the action
  10438. */
  10439. trigger: number;
  10440. /**
  10441. * Internal only - manager for action
  10442. * @hidden
  10443. */ actionManager: ActionManager;
  10444. private _nextActiveAction;
  10445. private _child;
  10446. private _condition?;
  10447. private _triggerParameter;
  10448. /**
  10449. * An event triggered prior to action being executed.
  10450. */
  10451. onBeforeExecuteObservable: Observable<Action>;
  10452. /**
  10453. * Creates a new Action
  10454. * @param triggerOptions the trigger, with or without parameters, for the action
  10455. * @param condition an optional determinant of action
  10456. */
  10457. constructor(
  10458. /** the trigger, with or without parameters, for the action */
  10459. triggerOptions: any, condition?: Condition);
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */ prepare(): void;
  10464. /**
  10465. * Gets the trigger parameters
  10466. * @returns the trigger parameters
  10467. */
  10468. getTriggerParameter(): any;
  10469. /**
  10470. * Internal only - executes current action event
  10471. * @hidden
  10472. */ executeCurrent(evt?: ActionEvent): void;
  10473. /**
  10474. * Execute placeholder for child classes
  10475. * @param evt optional action event
  10476. */
  10477. execute(evt?: ActionEvent): void;
  10478. /**
  10479. * Skips to next active action
  10480. */
  10481. skipToNextActiveAction(): void;
  10482. /**
  10483. * Adds action to chain of actions, may be a DoNothingAction
  10484. * @param action defines the next action to execute
  10485. * @returns The action passed in
  10486. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10487. */
  10488. then(action: Action): Action;
  10489. /**
  10490. * Internal only
  10491. * @hidden
  10492. */ getProperty(propertyPath: string): string;
  10493. /**
  10494. * Internal only
  10495. * @hidden
  10496. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10497. /**
  10498. * Serialize placeholder for child classes
  10499. * @param parent of child
  10500. * @returns the serialized object
  10501. */
  10502. serialize(parent: any): any;
  10503. /**
  10504. * Internal only called by serialize
  10505. * @hidden
  10506. */
  10507. protected _serialize(serializedAction: any, parent?: any): any;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */ private static _SerializeValueAsString: (value: any) => string;
  10512. /**
  10513. * Internal only
  10514. * @hidden
  10515. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10516. name: string;
  10517. targetType: string;
  10518. value: string;
  10519. };
  10520. }
  10521. }
  10522. declare module BABYLON {
  10523. /**
  10524. * A Condition applied to an Action
  10525. */
  10526. export class Condition {
  10527. /**
  10528. * Internal only - manager for action
  10529. * @hidden
  10530. */ actionManager: ActionManager;
  10531. /**
  10532. * Internal only
  10533. * @hidden
  10534. */ evaluationId: number;
  10535. /**
  10536. * Internal only
  10537. * @hidden
  10538. */ currentResult: boolean;
  10539. /**
  10540. * Creates a new Condition
  10541. * @param actionManager the manager of the action the condition is applied to
  10542. */
  10543. constructor(actionManager: ActionManager);
  10544. /**
  10545. * Check if the current condition is valid
  10546. * @returns a boolean
  10547. */
  10548. isValid(): boolean;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */ getProperty(propertyPath: string): string;
  10553. /**
  10554. * Internal only
  10555. * @hidden
  10556. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10557. /**
  10558. * Serialize placeholder for child classes
  10559. * @returns the serialized object
  10560. */
  10561. serialize(): any;
  10562. /**
  10563. * Internal only
  10564. * @hidden
  10565. */
  10566. protected _serialize(serializedCondition: any): any;
  10567. }
  10568. /**
  10569. * Defines specific conditional operators as extensions of Condition
  10570. */
  10571. export class ValueCondition extends Condition {
  10572. /** path to specify the property of the target the conditional operator uses */
  10573. propertyPath: string;
  10574. /** the value compared by the conditional operator against the current value of the property */
  10575. value: any;
  10576. /** the conditional operator, default ValueCondition.IsEqual */
  10577. operator: number;
  10578. /**
  10579. * Internal only
  10580. * @hidden
  10581. */
  10582. private static _IsEqual;
  10583. /**
  10584. * Internal only
  10585. * @hidden
  10586. */
  10587. private static _IsDifferent;
  10588. /**
  10589. * Internal only
  10590. * @hidden
  10591. */
  10592. private static _IsGreater;
  10593. /**
  10594. * Internal only
  10595. * @hidden
  10596. */
  10597. private static _IsLesser;
  10598. /**
  10599. * returns the number for IsEqual
  10600. */
  10601. static readonly IsEqual: number;
  10602. /**
  10603. * Returns the number for IsDifferent
  10604. */
  10605. static readonly IsDifferent: number;
  10606. /**
  10607. * Returns the number for IsGreater
  10608. */
  10609. static readonly IsGreater: number;
  10610. /**
  10611. * Returns the number for IsLesser
  10612. */
  10613. static readonly IsLesser: number;
  10614. /**
  10615. * Internal only The action manager for the condition
  10616. * @hidden
  10617. */ actionManager: ActionManager;
  10618. /**
  10619. * Internal only
  10620. * @hidden
  10621. */
  10622. private _target;
  10623. /**
  10624. * Internal only
  10625. * @hidden
  10626. */
  10627. private _effectiveTarget;
  10628. /**
  10629. * Internal only
  10630. * @hidden
  10631. */
  10632. private _property;
  10633. /**
  10634. * Creates a new ValueCondition
  10635. * @param actionManager manager for the action the condition applies to
  10636. * @param target for the action
  10637. * @param propertyPath path to specify the property of the target the conditional operator uses
  10638. * @param value the value compared by the conditional operator against the current value of the property
  10639. * @param operator the conditional operator, default ValueCondition.IsEqual
  10640. */
  10641. constructor(actionManager: ActionManager, target: any,
  10642. /** path to specify the property of the target the conditional operator uses */
  10643. propertyPath: string,
  10644. /** the value compared by the conditional operator against the current value of the property */
  10645. value: any,
  10646. /** the conditional operator, default ValueCondition.IsEqual */
  10647. operator?: number);
  10648. /**
  10649. * Compares the given value with the property value for the specified conditional operator
  10650. * @returns the result of the comparison
  10651. */
  10652. isValid(): boolean;
  10653. /**
  10654. * Serialize the ValueCondition into a JSON compatible object
  10655. * @returns serialization object
  10656. */
  10657. serialize(): any;
  10658. /**
  10659. * Gets the name of the conditional operator for the ValueCondition
  10660. * @param operator the conditional operator
  10661. * @returns the name
  10662. */
  10663. static GetOperatorName(operator: number): string;
  10664. }
  10665. /**
  10666. * Defines a predicate condition as an extension of Condition
  10667. */
  10668. export class PredicateCondition extends Condition {
  10669. /** defines the predicate function used to validate the condition */
  10670. predicate: () => boolean;
  10671. /**
  10672. * Internal only - manager for action
  10673. * @hidden
  10674. */ actionManager: ActionManager;
  10675. /**
  10676. * Creates a new PredicateCondition
  10677. * @param actionManager manager for the action the condition applies to
  10678. * @param predicate defines the predicate function used to validate the condition
  10679. */
  10680. constructor(actionManager: ActionManager,
  10681. /** defines the predicate function used to validate the condition */
  10682. predicate: () => boolean);
  10683. /**
  10684. * @returns the validity of the predicate condition
  10685. */
  10686. isValid(): boolean;
  10687. }
  10688. /**
  10689. * Defines a state condition as an extension of Condition
  10690. */
  10691. export class StateCondition extends Condition {
  10692. /** Value to compare with target state */
  10693. value: string;
  10694. /**
  10695. * Internal only - manager for action
  10696. * @hidden
  10697. */ actionManager: ActionManager;
  10698. /**
  10699. * Internal only
  10700. * @hidden
  10701. */
  10702. private _target;
  10703. /**
  10704. * Creates a new StateCondition
  10705. * @param actionManager manager for the action the condition applies to
  10706. * @param target of the condition
  10707. * @param value to compare with target state
  10708. */
  10709. constructor(actionManager: ActionManager, target: any,
  10710. /** Value to compare with target state */
  10711. value: string);
  10712. /**
  10713. * Gets a boolean indicating if the current condition is met
  10714. * @returns the validity of the state
  10715. */
  10716. isValid(): boolean;
  10717. /**
  10718. * Serialize the StateCondition into a JSON compatible object
  10719. * @returns serialization object
  10720. */
  10721. serialize(): any;
  10722. }
  10723. }
  10724. declare module BABYLON {
  10725. /**
  10726. * This defines an action responsible to toggle a boolean once triggered.
  10727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10728. */
  10729. export class SwitchBooleanAction extends Action {
  10730. /**
  10731. * The path to the boolean property in the target object
  10732. */
  10733. propertyPath: string;
  10734. private _target;
  10735. private _effectiveTarget;
  10736. private _property;
  10737. /**
  10738. * Instantiate the action
  10739. * @param triggerOptions defines the trigger options
  10740. * @param target defines the object containing the boolean
  10741. * @param propertyPath defines the path to the boolean property in the target object
  10742. * @param condition defines the trigger related conditions
  10743. */
  10744. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10745. /** @hidden */ prepare(): void;
  10746. /**
  10747. * Execute the action toggle the boolean value.
  10748. */
  10749. execute(): void;
  10750. /**
  10751. * Serializes the actions and its related information.
  10752. * @param parent defines the object to serialize in
  10753. * @returns the serialized object
  10754. */
  10755. serialize(parent: any): any;
  10756. }
  10757. /**
  10758. * This defines an action responsible to set a the state field of the target
  10759. * to a desired value once triggered.
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10761. */
  10762. export class SetStateAction extends Action {
  10763. /**
  10764. * The value to store in the state field.
  10765. */
  10766. value: string;
  10767. private _target;
  10768. /**
  10769. * Instantiate the action
  10770. * @param triggerOptions defines the trigger options
  10771. * @param target defines the object containing the state property
  10772. * @param value defines the value to store in the state field
  10773. * @param condition defines the trigger related conditions
  10774. */
  10775. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10776. /**
  10777. * Execute the action and store the value on the target state property.
  10778. */
  10779. execute(): void;
  10780. /**
  10781. * Serializes the actions and its related information.
  10782. * @param parent defines the object to serialize in
  10783. * @returns the serialized object
  10784. */
  10785. serialize(parent: any): any;
  10786. }
  10787. /**
  10788. * This defines an action responsible to set a property of the target
  10789. * to a desired value once triggered.
  10790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10791. */
  10792. export class SetValueAction extends Action {
  10793. /**
  10794. * The path of the property to set in the target.
  10795. */
  10796. propertyPath: string;
  10797. /**
  10798. * The value to set in the property
  10799. */
  10800. value: any;
  10801. private _target;
  10802. private _effectiveTarget;
  10803. private _property;
  10804. /**
  10805. * Instantiate the action
  10806. * @param triggerOptions defines the trigger options
  10807. * @param target defines the object containing the property
  10808. * @param propertyPath defines the path of the property to set in the target
  10809. * @param value defines the value to set in the property
  10810. * @param condition defines the trigger related conditions
  10811. */
  10812. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10813. /** @hidden */ prepare(): void;
  10814. /**
  10815. * Execute the action and set the targetted property to the desired value.
  10816. */
  10817. execute(): void;
  10818. /**
  10819. * Serializes the actions and its related information.
  10820. * @param parent defines the object to serialize in
  10821. * @returns the serialized object
  10822. */
  10823. serialize(parent: any): any;
  10824. }
  10825. /**
  10826. * This defines an action responsible to increment the target value
  10827. * to a desired value once triggered.
  10828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10829. */
  10830. export class IncrementValueAction extends Action {
  10831. /**
  10832. * The path of the property to increment in the target.
  10833. */
  10834. propertyPath: string;
  10835. /**
  10836. * The value we should increment the property by.
  10837. */
  10838. value: any;
  10839. private _target;
  10840. private _effectiveTarget;
  10841. private _property;
  10842. /**
  10843. * Instantiate the action
  10844. * @param triggerOptions defines the trigger options
  10845. * @param target defines the object containing the property
  10846. * @param propertyPath defines the path of the property to increment in the target
  10847. * @param value defines the value value we should increment the property by
  10848. * @param condition defines the trigger related conditions
  10849. */
  10850. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10851. /** @hidden */ prepare(): void;
  10852. /**
  10853. * Execute the action and increment the target of the value amount.
  10854. */
  10855. execute(): void;
  10856. /**
  10857. * Serializes the actions and its related information.
  10858. * @param parent defines the object to serialize in
  10859. * @returns the serialized object
  10860. */
  10861. serialize(parent: any): any;
  10862. }
  10863. /**
  10864. * This defines an action responsible to start an animation once triggered.
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10866. */
  10867. export class PlayAnimationAction extends Action {
  10868. /**
  10869. * Where the animation should start (animation frame)
  10870. */
  10871. from: number;
  10872. /**
  10873. * Where the animation should stop (animation frame)
  10874. */
  10875. to: number;
  10876. /**
  10877. * Define if the animation should loop or stop after the first play.
  10878. */
  10879. loop?: boolean;
  10880. private _target;
  10881. /**
  10882. * Instantiate the action
  10883. * @param triggerOptions defines the trigger options
  10884. * @param target defines the target animation or animation name
  10885. * @param from defines from where the animation should start (animation frame)
  10886. * @param end defines where the animation should stop (animation frame)
  10887. * @param loop defines if the animation should loop or stop after the first play
  10888. * @param condition defines the trigger related conditions
  10889. */
  10890. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10891. /** @hidden */ prepare(): void;
  10892. /**
  10893. * Execute the action and play the animation.
  10894. */
  10895. execute(): void;
  10896. /**
  10897. * Serializes the actions and its related information.
  10898. * @param parent defines the object to serialize in
  10899. * @returns the serialized object
  10900. */
  10901. serialize(parent: any): any;
  10902. }
  10903. /**
  10904. * This defines an action responsible to stop an animation once triggered.
  10905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10906. */
  10907. export class StopAnimationAction extends Action {
  10908. private _target;
  10909. /**
  10910. * Instantiate the action
  10911. * @param triggerOptions defines the trigger options
  10912. * @param target defines the target animation or animation name
  10913. * @param condition defines the trigger related conditions
  10914. */
  10915. constructor(triggerOptions: any, target: any, condition?: Condition);
  10916. /** @hidden */ prepare(): void;
  10917. /**
  10918. * Execute the action and stop the animation.
  10919. */
  10920. execute(): void;
  10921. /**
  10922. * Serializes the actions and its related information.
  10923. * @param parent defines the object to serialize in
  10924. * @returns the serialized object
  10925. */
  10926. serialize(parent: any): any;
  10927. }
  10928. /**
  10929. * This defines an action responsible that does nothing once triggered.
  10930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10931. */
  10932. export class DoNothingAction extends Action {
  10933. /**
  10934. * Instantiate the action
  10935. * @param triggerOptions defines the trigger options
  10936. * @param condition defines the trigger related conditions
  10937. */
  10938. constructor(triggerOptions?: any, condition?: Condition);
  10939. /**
  10940. * Execute the action and do nothing.
  10941. */
  10942. execute(): void;
  10943. /**
  10944. * Serializes the actions and its related information.
  10945. * @param parent defines the object to serialize in
  10946. * @returns the serialized object
  10947. */
  10948. serialize(parent: any): any;
  10949. }
  10950. /**
  10951. * This defines an action responsible to trigger several actions once triggered.
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10953. */
  10954. export class CombineAction extends Action {
  10955. /**
  10956. * The list of aggregated animations to run.
  10957. */
  10958. children: Action[];
  10959. /**
  10960. * Instantiate the action
  10961. * @param triggerOptions defines the trigger options
  10962. * @param children defines the list of aggregated animations to run
  10963. * @param condition defines the trigger related conditions
  10964. */
  10965. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10966. /** @hidden */ prepare(): void;
  10967. /**
  10968. * Execute the action and executes all the aggregated actions.
  10969. */
  10970. execute(evt: ActionEvent): void;
  10971. /**
  10972. * Serializes the actions and its related information.
  10973. * @param parent defines the object to serialize in
  10974. * @returns the serialized object
  10975. */
  10976. serialize(parent: any): any;
  10977. }
  10978. /**
  10979. * This defines an action responsible to run code (external event) once triggered.
  10980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10981. */
  10982. export class ExecuteCodeAction extends Action {
  10983. /**
  10984. * The callback function to run.
  10985. */
  10986. func: (evt: ActionEvent) => void;
  10987. /**
  10988. * Instantiate the action
  10989. * @param triggerOptions defines the trigger options
  10990. * @param func defines the callback function to run
  10991. * @param condition defines the trigger related conditions
  10992. */
  10993. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10994. /**
  10995. * Execute the action and run the attached code.
  10996. */
  10997. execute(evt: ActionEvent): void;
  10998. }
  10999. /**
  11000. * This defines an action responsible to set the parent property of the target once triggered.
  11001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11002. */
  11003. export class SetParentAction extends Action {
  11004. private _parent;
  11005. private _target;
  11006. /**
  11007. * Instantiate the action
  11008. * @param triggerOptions defines the trigger options
  11009. * @param target defines the target containing the parent property
  11010. * @param parent defines from where the animation should start (animation frame)
  11011. * @param condition defines the trigger related conditions
  11012. */
  11013. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11014. /** @hidden */ prepare(): void;
  11015. /**
  11016. * Execute the action and set the parent property.
  11017. */
  11018. execute(): void;
  11019. /**
  11020. * Serializes the actions and its related information.
  11021. * @param parent defines the object to serialize in
  11022. * @returns the serialized object
  11023. */
  11024. serialize(parent: any): any;
  11025. }
  11026. }
  11027. declare module BABYLON {
  11028. /**
  11029. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11030. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11032. */
  11033. export class ActionManager extends AbstractActionManager {
  11034. /**
  11035. * Nothing
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly NothingTrigger: number;
  11039. /**
  11040. * On pick
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnPickTrigger: number;
  11044. /**
  11045. * On left pick
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnLeftPickTrigger: number;
  11049. /**
  11050. * On right pick
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnRightPickTrigger: number;
  11054. /**
  11055. * On center pick
  11056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11057. */
  11058. static readonly OnCenterPickTrigger: number;
  11059. /**
  11060. * On pick down
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11062. */
  11063. static readonly OnPickDownTrigger: number;
  11064. /**
  11065. * On double pick
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnDoublePickTrigger: number;
  11069. /**
  11070. * On pick up
  11071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11072. */
  11073. static readonly OnPickUpTrigger: number;
  11074. /**
  11075. * On pick out.
  11076. * This trigger will only be raised if you also declared a OnPickDown
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnPickOutTrigger: number;
  11080. /**
  11081. * On long press
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnLongPressTrigger: number;
  11085. /**
  11086. * On pointer over
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnPointerOverTrigger: number;
  11090. /**
  11091. * On pointer out
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnPointerOutTrigger: number;
  11095. /**
  11096. * On every frame
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnEveryFrameTrigger: number;
  11100. /**
  11101. * On intersection enter
  11102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11103. */
  11104. static readonly OnIntersectionEnterTrigger: number;
  11105. /**
  11106. * On intersection exit
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11108. */
  11109. static readonly OnIntersectionExitTrigger: number;
  11110. /**
  11111. * On key down
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11113. */
  11114. static readonly OnKeyDownTrigger: number;
  11115. /**
  11116. * On key up
  11117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11118. */
  11119. static readonly OnKeyUpTrigger: number;
  11120. private _scene;
  11121. /**
  11122. * Creates a new action manager
  11123. * @param scene defines the hosting scene
  11124. */
  11125. constructor(scene: Scene);
  11126. /**
  11127. * Releases all associated resources
  11128. */
  11129. dispose(): void;
  11130. /**
  11131. * Gets hosting scene
  11132. * @returns the hosting scene
  11133. */
  11134. getScene(): Scene;
  11135. /**
  11136. * Does this action manager handles actions of any of the given triggers
  11137. * @param triggers defines the triggers to be tested
  11138. * @return a boolean indicating whether one (or more) of the triggers is handled
  11139. */
  11140. hasSpecificTriggers(triggers: number[]): boolean;
  11141. /**
  11142. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11143. * speed.
  11144. * @param triggerA defines the trigger to be tested
  11145. * @param triggerB defines the trigger to be tested
  11146. * @return a boolean indicating whether one (or more) of the triggers is handled
  11147. */
  11148. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11149. /**
  11150. * Does this action manager handles actions of a given trigger
  11151. * @param trigger defines the trigger to be tested
  11152. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11153. * @return whether the trigger is handled
  11154. */
  11155. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11156. /**
  11157. * Does this action manager has pointer triggers
  11158. */
  11159. readonly hasPointerTriggers: boolean;
  11160. /**
  11161. * Does this action manager has pick triggers
  11162. */
  11163. readonly hasPickTriggers: boolean;
  11164. /**
  11165. * Registers an action to this action manager
  11166. * @param action defines the action to be registered
  11167. * @return the action amended (prepared) after registration
  11168. */
  11169. registerAction(action: IAction): Nullable<IAction>;
  11170. /**
  11171. * Unregisters an action to this action manager
  11172. * @param action defines the action to be unregistered
  11173. * @return a boolean indicating whether the action has been unregistered
  11174. */
  11175. unregisterAction(action: IAction): Boolean;
  11176. /**
  11177. * Process a specific trigger
  11178. * @param trigger defines the trigger to process
  11179. * @param evt defines the event details to be processed
  11180. */
  11181. processTrigger(trigger: number, evt?: IActionEvent): void;
  11182. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  11183. /** @hidden */ getProperty(propertyPath: string): string;
  11184. /**
  11185. * Serialize this manager to a JSON object
  11186. * @param name defines the property name to store this manager
  11187. * @returns a JSON representation of this manager
  11188. */
  11189. serialize(name: string): any;
  11190. /**
  11191. * Creates a new ActionManager from a JSON data
  11192. * @param parsedActions defines the JSON data to read from
  11193. * @param object defines the hosting mesh
  11194. * @param scene defines the hosting scene
  11195. */
  11196. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11197. /**
  11198. * Get a trigger name by index
  11199. * @param trigger defines the trigger index
  11200. * @returns a trigger name
  11201. */
  11202. static GetTriggerName(trigger: number): string;
  11203. }
  11204. }
  11205. declare module BABYLON {
  11206. /**
  11207. * Class representing a ray with position and direction
  11208. */
  11209. export class Ray {
  11210. /** origin point */
  11211. origin: Vector3;
  11212. /** direction */
  11213. direction: Vector3;
  11214. /** length of the ray */
  11215. length: number;
  11216. private static readonly TmpVector3;
  11217. private _tmpRay;
  11218. /**
  11219. * Creates a new ray
  11220. * @param origin origin point
  11221. * @param direction direction
  11222. * @param length length of the ray
  11223. */
  11224. constructor(
  11225. /** origin point */
  11226. origin: Vector3,
  11227. /** direction */
  11228. direction: Vector3,
  11229. /** length of the ray */
  11230. length?: number);
  11231. /**
  11232. * Checks if the ray intersects a box
  11233. * @param minimum bound of the box
  11234. * @param maximum bound of the box
  11235. * @param intersectionTreshold extra extend to be added to the box in all direction
  11236. * @returns if the box was hit
  11237. */
  11238. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11239. /**
  11240. * Checks if the ray intersects a box
  11241. * @param box the bounding box to check
  11242. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11243. * @returns if the box was hit
  11244. */
  11245. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11246. /**
  11247. * If the ray hits a sphere
  11248. * @param sphere the bounding sphere to check
  11249. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11250. * @returns true if it hits the sphere
  11251. */
  11252. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11253. /**
  11254. * If the ray hits a triange
  11255. * @param vertex0 triangle vertex
  11256. * @param vertex1 triangle vertex
  11257. * @param vertex2 triangle vertex
  11258. * @returns intersection information if hit
  11259. */
  11260. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11261. /**
  11262. * Checks if ray intersects a plane
  11263. * @param plane the plane to check
  11264. * @returns the distance away it was hit
  11265. */
  11266. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11267. /**
  11268. * Checks if ray intersects a mesh
  11269. * @param mesh the mesh to check
  11270. * @param fastCheck if only the bounding box should checked
  11271. * @returns picking info of the intersecton
  11272. */
  11273. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11274. /**
  11275. * Checks if ray intersects a mesh
  11276. * @param meshes the meshes to check
  11277. * @param fastCheck if only the bounding box should checked
  11278. * @param results array to store result in
  11279. * @returns Array of picking infos
  11280. */
  11281. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11282. private _comparePickingInfo;
  11283. private static smallnum;
  11284. private static rayl;
  11285. /**
  11286. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11287. * @param sega the first point of the segment to test the intersection against
  11288. * @param segb the second point of the segment to test the intersection against
  11289. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11290. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11291. */
  11292. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11293. /**
  11294. * Update the ray from viewport position
  11295. * @param x position
  11296. * @param y y position
  11297. * @param viewportWidth viewport width
  11298. * @param viewportHeight viewport height
  11299. * @param world world matrix
  11300. * @param view view matrix
  11301. * @param projection projection matrix
  11302. * @returns this ray updated
  11303. */
  11304. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11305. /**
  11306. * Creates a ray with origin and direction of 0,0,0
  11307. * @returns the new ray
  11308. */
  11309. static Zero(): Ray;
  11310. /**
  11311. * Creates a new ray from screen space and viewport
  11312. * @param x position
  11313. * @param y y position
  11314. * @param viewportWidth viewport width
  11315. * @param viewportHeight viewport height
  11316. * @param world world matrix
  11317. * @param view view matrix
  11318. * @param projection projection matrix
  11319. * @returns new ray
  11320. */
  11321. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11322. /**
  11323. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11324. * transformed to the given world matrix.
  11325. * @param origin The origin point
  11326. * @param end The end point
  11327. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11328. * @returns the new ray
  11329. */
  11330. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11331. /**
  11332. * Transforms a ray by a matrix
  11333. * @param ray ray to transform
  11334. * @param matrix matrix to apply
  11335. * @returns the resulting new ray
  11336. */
  11337. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11338. /**
  11339. * Transforms a ray by a matrix
  11340. * @param ray ray to transform
  11341. * @param matrix matrix to apply
  11342. * @param result ray to store result in
  11343. */
  11344. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11345. /**
  11346. * Unproject a ray from screen space to object space
  11347. * @param sourceX defines the screen space x coordinate to use
  11348. * @param sourceY defines the screen space y coordinate to use
  11349. * @param viewportWidth defines the current width of the viewport
  11350. * @param viewportHeight defines the current height of the viewport
  11351. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11352. * @param view defines the view matrix to use
  11353. * @param projection defines the projection matrix to use
  11354. */
  11355. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11356. }
  11357. /**
  11358. * Type used to define predicate used to select faces when a mesh intersection is detected
  11359. */
  11360. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11361. interface Scene {
  11362. /** @hidden */ tempPickingRay: Nullable<Ray>;
  11363. /** @hidden */ cachedRayForTransform: Ray;
  11364. /** @hidden */ pickWithRayInverseMatrix: Matrix;
  11365. /** @hidden */ internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11366. /** @hidden */ internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11367. }
  11368. }
  11369. declare module BABYLON {
  11370. /**
  11371. * Groups all the scene component constants in one place to ease maintenance.
  11372. * @hidden
  11373. */
  11374. export class SceneComponentConstants {
  11375. static readonly NAME_EFFECTLAYER: string;
  11376. static readonly NAME_LAYER: string;
  11377. static readonly NAME_LENSFLARESYSTEM: string;
  11378. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11379. static readonly NAME_PARTICLESYSTEM: string;
  11380. static readonly NAME_GAMEPAD: string;
  11381. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11382. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11383. static readonly NAME_DEPTHRENDERER: string;
  11384. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11385. static readonly NAME_SPRITE: string;
  11386. static readonly NAME_OUTLINERENDERER: string;
  11387. static readonly NAME_PROCEDURALTEXTURE: string;
  11388. static readonly NAME_SHADOWGENERATOR: string;
  11389. static readonly NAME_OCTREE: string;
  11390. static readonly NAME_PHYSICSENGINE: string;
  11391. static readonly NAME_AUDIO: string;
  11392. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11393. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11394. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11395. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11396. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11397. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11398. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11399. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11400. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11401. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11402. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11403. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11404. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11405. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11406. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11407. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11408. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11409. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11410. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11411. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11412. static readonly STEP_AFTERRENDER_AUDIO: number;
  11413. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11414. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11415. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11416. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11417. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11418. static readonly STEP_POINTERMOVE_SPRITE: number;
  11419. static readonly STEP_POINTERDOWN_SPRITE: number;
  11420. static readonly STEP_POINTERUP_SPRITE: number;
  11421. }
  11422. /**
  11423. * This represents a scene component.
  11424. *
  11425. * This is used to decouple the dependency the scene is having on the different workloads like
  11426. * layers, post processes...
  11427. */
  11428. export interface ISceneComponent {
  11429. /**
  11430. * The name of the component. Each component must have a unique name.
  11431. */
  11432. name: string;
  11433. /**
  11434. * The scene the component belongs to.
  11435. */
  11436. scene: Scene;
  11437. /**
  11438. * Register the component to one instance of a scene.
  11439. */
  11440. register(): void;
  11441. /**
  11442. * Rebuilds the elements related to this component in case of
  11443. * context lost for instance.
  11444. */
  11445. rebuild(): void;
  11446. /**
  11447. * Disposes the component and the associated ressources.
  11448. */
  11449. dispose(): void;
  11450. }
  11451. /**
  11452. * This represents a SERIALIZABLE scene component.
  11453. *
  11454. * This extends Scene Component to add Serialization methods on top.
  11455. */
  11456. export interface ISceneSerializableComponent extends ISceneComponent {
  11457. /**
  11458. * Adds all the element from the container to the scene
  11459. * @param container the container holding the elements
  11460. */
  11461. addFromContainer(container: AbstractScene): void;
  11462. /**
  11463. * Removes all the elements in the container from the scene
  11464. * @param container contains the elements to remove
  11465. * @param dispose if the removed element should be disposed (default: false)
  11466. */
  11467. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11468. /**
  11469. * Serializes the component data to the specified json object
  11470. * @param serializationObject The object to serialize to
  11471. */
  11472. serialize(serializationObject: any): void;
  11473. }
  11474. /**
  11475. * Strong typing of a Mesh related stage step action
  11476. */
  11477. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11478. /**
  11479. * Strong typing of a Evaluate Sub Mesh related stage step action
  11480. */
  11481. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11482. /**
  11483. * Strong typing of a Active Mesh related stage step action
  11484. */
  11485. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11486. /**
  11487. * Strong typing of a Camera related stage step action
  11488. */
  11489. export type CameraStageAction = (camera: Camera) => void;
  11490. /**
  11491. * Strong typing of a Camera Frame buffer related stage step action
  11492. */
  11493. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11494. /**
  11495. * Strong typing of a Render Target related stage step action
  11496. */
  11497. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11498. /**
  11499. * Strong typing of a RenderingGroup related stage step action
  11500. */
  11501. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11502. /**
  11503. * Strong typing of a Mesh Render related stage step action
  11504. */
  11505. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11506. /**
  11507. * Strong typing of a simple stage step action
  11508. */
  11509. export type SimpleStageAction = () => void;
  11510. /**
  11511. * Strong typing of a render target action.
  11512. */
  11513. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11514. /**
  11515. * Strong typing of a pointer move action.
  11516. */
  11517. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11518. /**
  11519. * Strong typing of a pointer up/down action.
  11520. */
  11521. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11522. /**
  11523. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11524. * @hidden
  11525. */
  11526. export class Stage<T extends Function> extends Array<{
  11527. index: number;
  11528. component: ISceneComponent;
  11529. action: T;
  11530. }> {
  11531. /**
  11532. * Hide ctor from the rest of the world.
  11533. * @param items The items to add.
  11534. */
  11535. private constructor();
  11536. /**
  11537. * Creates a new Stage.
  11538. * @returns A new instance of a Stage
  11539. */
  11540. static Create<T extends Function>(): Stage<T>;
  11541. /**
  11542. * Registers a step in an ordered way in the targeted stage.
  11543. * @param index Defines the position to register the step in
  11544. * @param component Defines the component attached to the step
  11545. * @param action Defines the action to launch during the step
  11546. */
  11547. registerStep(index: number, component: ISceneComponent, action: T): void;
  11548. /**
  11549. * Clears all the steps from the stage.
  11550. */
  11551. clear(): void;
  11552. }
  11553. }
  11554. declare module BABYLON {
  11555. interface Scene {
  11556. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  11557. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  11558. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  11559. /**
  11560. * All of the sprite managers added to this scene
  11561. * @see http://doc.babylonjs.com/babylon101/sprites
  11562. */
  11563. spriteManagers: Array<ISpriteManager>;
  11564. /**
  11565. * An event triggered when sprites rendering is about to start
  11566. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11567. */
  11568. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11569. /**
  11570. * An event triggered when sprites rendering is done
  11571. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11572. */
  11573. onAfterSpritesRenderingObservable: Observable<Scene>;
  11574. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11575. /** Launch a ray to try to pick a sprite in the scene
  11576. * @param x position on screen
  11577. * @param y position on screen
  11578. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11579. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11580. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11581. * @returns a PickingInfo
  11582. */
  11583. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11584. /** Use the given ray to pick a sprite in the scene
  11585. * @param ray The ray (in world space) to use to pick meshes
  11586. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11587. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11588. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11589. * @returns a PickingInfo
  11590. */
  11591. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11592. /**
  11593. * Force the sprite under the pointer
  11594. * @param sprite defines the sprite to use
  11595. */
  11596. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11597. /**
  11598. * Gets the sprite under the pointer
  11599. * @returns a Sprite or null if no sprite is under the pointer
  11600. */
  11601. getPointerOverSprite(): Nullable<Sprite>;
  11602. }
  11603. /**
  11604. * Defines the sprite scene component responsible to manage sprites
  11605. * in a given scene.
  11606. */
  11607. export class SpriteSceneComponent implements ISceneComponent {
  11608. /**
  11609. * The component name helpfull to identify the component in the list of scene components.
  11610. */
  11611. readonly name: string;
  11612. /**
  11613. * The scene the component belongs to.
  11614. */
  11615. scene: Scene;
  11616. /** @hidden */
  11617. private _spritePredicate;
  11618. /**
  11619. * Creates a new instance of the component for the given scene
  11620. * @param scene Defines the scene to register the component in
  11621. */
  11622. constructor(scene: Scene);
  11623. /**
  11624. * Registers the component in a given scene
  11625. */
  11626. register(): void;
  11627. /**
  11628. * Rebuilds the elements related to this component in case of
  11629. * context lost for instance.
  11630. */
  11631. rebuild(): void;
  11632. /**
  11633. * Disposes the component and the associated ressources.
  11634. */
  11635. dispose(): void;
  11636. private _pickSpriteButKeepRay;
  11637. private _pointerMove;
  11638. private _pointerDown;
  11639. private _pointerUp;
  11640. }
  11641. }
  11642. declare module BABYLON {
  11643. /** @hidden */
  11644. export var fogFragmentDeclaration: {
  11645. name: string;
  11646. shader: string;
  11647. };
  11648. }
  11649. declare module BABYLON {
  11650. /** @hidden */
  11651. export var fogFragment: {
  11652. name: string;
  11653. shader: string;
  11654. };
  11655. }
  11656. declare module BABYLON {
  11657. /** @hidden */
  11658. export var spritesPixelShader: {
  11659. name: string;
  11660. shader: string;
  11661. };
  11662. }
  11663. declare module BABYLON {
  11664. /** @hidden */
  11665. export var fogVertexDeclaration: {
  11666. name: string;
  11667. shader: string;
  11668. };
  11669. }
  11670. declare module BABYLON {
  11671. /** @hidden */
  11672. export var spritesVertexShader: {
  11673. name: string;
  11674. shader: string;
  11675. };
  11676. }
  11677. declare module BABYLON {
  11678. /**
  11679. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11680. */
  11681. export interface ISpriteManager extends IDisposable {
  11682. /**
  11683. * Restricts the camera to viewing objects with the same layerMask.
  11684. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11685. */
  11686. layerMask: number;
  11687. /**
  11688. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11689. */
  11690. isPickable: boolean;
  11691. /**
  11692. * Specifies the rendering group id for this mesh (0 by default)
  11693. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11694. */
  11695. renderingGroupId: number;
  11696. /**
  11697. * Defines the list of sprites managed by the manager.
  11698. */
  11699. sprites: Array<Sprite>;
  11700. /**
  11701. * Tests the intersection of a sprite with a specific ray.
  11702. * @param ray The ray we are sending to test the collision
  11703. * @param camera The camera space we are sending rays in
  11704. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11705. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11706. * @returns picking info or null.
  11707. */
  11708. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11709. /**
  11710. * Renders the list of sprites on screen.
  11711. */
  11712. render(): void;
  11713. }
  11714. /**
  11715. * Class used to manage multiple sprites on the same spritesheet
  11716. * @see http://doc.babylonjs.com/babylon101/sprites
  11717. */
  11718. export class SpriteManager implements ISpriteManager {
  11719. /** defines the manager's name */
  11720. name: string;
  11721. /** Gets the list of sprites */
  11722. sprites: Sprite[];
  11723. /** Gets or sets the rendering group id (0 by default) */
  11724. renderingGroupId: number;
  11725. /** Gets or sets camera layer mask */
  11726. layerMask: number;
  11727. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11728. fogEnabled: boolean;
  11729. /** Gets or sets a boolean indicating if the sprites are pickable */
  11730. isPickable: boolean;
  11731. /** Defines the default width of a cell in the spritesheet */
  11732. cellWidth: number;
  11733. /** Defines the default height of a cell in the spritesheet */
  11734. cellHeight: number;
  11735. /**
  11736. * An event triggered when the manager is disposed.
  11737. */
  11738. onDisposeObservable: Observable<SpriteManager>;
  11739. private _onDisposeObserver;
  11740. /**
  11741. * Callback called when the manager is disposed
  11742. */
  11743. onDispose: () => void;
  11744. private _capacity;
  11745. private _spriteTexture;
  11746. private _epsilon;
  11747. private _scene;
  11748. private _vertexData;
  11749. private _buffer;
  11750. private _vertexBuffers;
  11751. private _indexBuffer;
  11752. private _effectBase;
  11753. private _effectFog;
  11754. /**
  11755. * Gets or sets the spritesheet texture
  11756. */
  11757. texture: Texture;
  11758. /**
  11759. * Creates a new sprite manager
  11760. * @param name defines the manager's name
  11761. * @param imgUrl defines the sprite sheet url
  11762. * @param capacity defines the maximum allowed number of sprites
  11763. * @param cellSize defines the size of a sprite cell
  11764. * @param scene defines the hosting scene
  11765. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11766. * @param samplingMode defines the smapling mode to use with spritesheet
  11767. */
  11768. constructor(
  11769. /** defines the manager's name */
  11770. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11771. private _appendSpriteVertex;
  11772. /**
  11773. * Intersects the sprites with a ray
  11774. * @param ray defines the ray to intersect with
  11775. * @param camera defines the current active camera
  11776. * @param predicate defines a predicate used to select candidate sprites
  11777. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11778. * @returns null if no hit or a PickingInfo
  11779. */
  11780. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11781. /**
  11782. * Render all child sprites
  11783. */
  11784. render(): void;
  11785. /**
  11786. * Release associated resources
  11787. */
  11788. dispose(): void;
  11789. }
  11790. }
  11791. declare module BABYLON {
  11792. /**
  11793. * Class used to represent a sprite
  11794. * @see http://doc.babylonjs.com/babylon101/sprites
  11795. */
  11796. export class Sprite {
  11797. /** defines the name */
  11798. name: string;
  11799. /** Gets or sets the current world position */
  11800. position: Vector3;
  11801. /** Gets or sets the main color */
  11802. color: Color4;
  11803. /** Gets or sets the width */
  11804. width: number;
  11805. /** Gets or sets the height */
  11806. height: number;
  11807. /** Gets or sets rotation angle */
  11808. angle: number;
  11809. /** Gets or sets the cell index in the sprite sheet */
  11810. cellIndex: number;
  11811. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11812. invertU: number;
  11813. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11814. invertV: number;
  11815. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11816. disposeWhenFinishedAnimating: boolean;
  11817. /** Gets the list of attached animations */
  11818. animations: Animation[];
  11819. /** Gets or sets a boolean indicating if the sprite can be picked */
  11820. isPickable: boolean;
  11821. /**
  11822. * Gets or sets the associated action manager
  11823. */
  11824. actionManager: Nullable<ActionManager>;
  11825. private _animationStarted;
  11826. private _loopAnimation;
  11827. private _fromIndex;
  11828. private _toIndex;
  11829. private _delay;
  11830. private _direction;
  11831. private _manager;
  11832. private _time;
  11833. private _onAnimationEnd;
  11834. /**
  11835. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11836. */
  11837. isVisible: boolean;
  11838. /**
  11839. * Gets or sets the sprite size
  11840. */
  11841. size: number;
  11842. /**
  11843. * Creates a new Sprite
  11844. * @param name defines the name
  11845. * @param manager defines the manager
  11846. */
  11847. constructor(
  11848. /** defines the name */
  11849. name: string, manager: ISpriteManager);
  11850. /**
  11851. * Starts an animation
  11852. * @param from defines the initial key
  11853. * @param to defines the end key
  11854. * @param loop defines if the animation must loop
  11855. * @param delay defines the start delay (in ms)
  11856. * @param onAnimationEnd defines a callback to call when animation ends
  11857. */
  11858. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11859. /** Stops current animation (if any) */
  11860. stopAnimation(): void;
  11861. /** @hidden */ animate(deltaTime: number): void;
  11862. /** Release associated resources */
  11863. dispose(): void;
  11864. }
  11865. }
  11866. declare module BABYLON {
  11867. /**
  11868. * Information about the result of picking within a scene
  11869. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11870. */
  11871. export class PickingInfo {
  11872. /** @hidden */ pickingUnavailable: boolean;
  11873. /**
  11874. * If the pick collided with an object
  11875. */
  11876. hit: boolean;
  11877. /**
  11878. * Distance away where the pick collided
  11879. */
  11880. distance: number;
  11881. /**
  11882. * The location of pick collision
  11883. */
  11884. pickedPoint: Nullable<Vector3>;
  11885. /**
  11886. * The mesh corresponding the the pick collision
  11887. */
  11888. pickedMesh: Nullable<AbstractMesh>;
  11889. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11890. bu: number;
  11891. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11892. bv: number;
  11893. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11894. faceId: number;
  11895. /** Id of the the submesh that was picked */
  11896. subMeshId: number;
  11897. /** If a sprite was picked, this will be the sprite the pick collided with */
  11898. pickedSprite: Nullable<Sprite>;
  11899. /**
  11900. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11901. */
  11902. originMesh: Nullable<AbstractMesh>;
  11903. /**
  11904. * The ray that was used to perform the picking.
  11905. */
  11906. ray: Nullable<Ray>;
  11907. /**
  11908. * Gets the normal correspodning to the face the pick collided with
  11909. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11910. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11911. * @returns The normal correspodning to the face the pick collided with
  11912. */
  11913. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11914. /**
  11915. * Gets the texture coordinates of where the pick occured
  11916. * @returns the vector containing the coordnates of the texture
  11917. */
  11918. getTextureCoordinates(): Nullable<Vector2>;
  11919. }
  11920. }
  11921. declare module BABYLON {
  11922. /**
  11923. * Gather the list of pointer event types as constants.
  11924. */
  11925. export class PointerEventTypes {
  11926. /**
  11927. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11928. */
  11929. static readonly POINTERDOWN: number;
  11930. /**
  11931. * The pointerup event is fired when a pointer is no longer active.
  11932. */
  11933. static readonly POINTERUP: number;
  11934. /**
  11935. * The pointermove event is fired when a pointer changes coordinates.
  11936. */
  11937. static readonly POINTERMOVE: number;
  11938. /**
  11939. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11940. */
  11941. static readonly POINTERWHEEL: number;
  11942. /**
  11943. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11944. */
  11945. static readonly POINTERPICK: number;
  11946. /**
  11947. * The pointertap event is fired when a the object has been touched and released without drag.
  11948. */
  11949. static readonly POINTERTAP: number;
  11950. /**
  11951. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11952. */
  11953. static readonly POINTERDOUBLETAP: number;
  11954. }
  11955. /**
  11956. * Base class of pointer info types.
  11957. */
  11958. export class PointerInfoBase {
  11959. /**
  11960. * Defines the type of event (PointerEventTypes)
  11961. */
  11962. type: number;
  11963. /**
  11964. * Defines the related dom event
  11965. */
  11966. event: PointerEvent | MouseWheelEvent;
  11967. /**
  11968. * Instantiates the base class of pointers info.
  11969. * @param type Defines the type of event (PointerEventTypes)
  11970. * @param event Defines the related dom event
  11971. */
  11972. constructor(
  11973. /**
  11974. * Defines the type of event (PointerEventTypes)
  11975. */
  11976. type: number,
  11977. /**
  11978. * Defines the related dom event
  11979. */
  11980. event: PointerEvent | MouseWheelEvent);
  11981. }
  11982. /**
  11983. * This class is used to store pointer related info for the onPrePointerObservable event.
  11984. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11985. */
  11986. export class PointerInfoPre extends PointerInfoBase {
  11987. /**
  11988. * Ray from a pointer if availible (eg. 6dof controller)
  11989. */
  11990. ray: Nullable<Ray>;
  11991. /**
  11992. * Defines the local position of the pointer on the canvas.
  11993. */
  11994. localPosition: Vector2;
  11995. /**
  11996. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11997. */
  11998. skipOnPointerObservable: boolean;
  11999. /**
  12000. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12001. * @param type Defines the type of event (PointerEventTypes)
  12002. * @param event Defines the related dom event
  12003. * @param localX Defines the local x coordinates of the pointer when the event occured
  12004. * @param localY Defines the local y coordinates of the pointer when the event occured
  12005. */
  12006. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12007. }
  12008. /**
  12009. * This type contains all the data related to a pointer event in Babylon.js.
  12010. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  12011. */
  12012. export class PointerInfo extends PointerInfoBase {
  12013. /**
  12014. * Defines the picking info associated to the info (if any)\
  12015. */
  12016. pickInfo: Nullable<PickingInfo>;
  12017. /**
  12018. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12019. * @param type Defines the type of event (PointerEventTypes)
  12020. * @param event Defines the related dom event
  12021. * @param pickInfo Defines the picking info associated to the info (if any)\
  12022. */
  12023. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12024. /**
  12025. * Defines the picking info associated to the info (if any)\
  12026. */
  12027. pickInfo: Nullable<PickingInfo>);
  12028. }
  12029. /**
  12030. * Data relating to a touch event on the screen.
  12031. */
  12032. export interface PointerTouch {
  12033. /**
  12034. * X coordinate of touch.
  12035. */
  12036. x: number;
  12037. /**
  12038. * Y coordinate of touch.
  12039. */
  12040. y: number;
  12041. /**
  12042. * Id of touch. Unique for each finger.
  12043. */
  12044. pointerId: number;
  12045. /**
  12046. * Event type passed from DOM.
  12047. */
  12048. type: any;
  12049. }
  12050. }
  12051. declare module BABYLON {
  12052. /**
  12053. * Manage the mouse inputs to control the movement of a free camera.
  12054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12055. */
  12056. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12057. /**
  12058. * Define if touch is enabled in the mouse input
  12059. */
  12060. touchEnabled: boolean;
  12061. /**
  12062. * Defines the camera the input is attached to.
  12063. */
  12064. camera: FreeCamera;
  12065. /**
  12066. * Defines the buttons associated with the input to handle camera move.
  12067. */
  12068. buttons: number[];
  12069. /**
  12070. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12071. */
  12072. angularSensibility: number;
  12073. private _pointerInput;
  12074. private _onMouseMove;
  12075. private _observer;
  12076. private previousPosition;
  12077. /**
  12078. * Observable for when a pointer move event occurs containing the move offset
  12079. */
  12080. onPointerMovedObservable: Observable<{
  12081. offsetX: number;
  12082. offsetY: number;
  12083. }>;
  12084. /**
  12085. * @hidden
  12086. * If the camera should be rotated automatically based on pointer movement
  12087. */ allowCameraRotation: boolean;
  12088. /**
  12089. * Manage the mouse inputs to control the movement of a free camera.
  12090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12091. * @param touchEnabled Defines if touch is enabled or not
  12092. */
  12093. constructor(
  12094. /**
  12095. * Define if touch is enabled in the mouse input
  12096. */
  12097. touchEnabled?: boolean);
  12098. /**
  12099. * Attach the input controls to a specific dom element to get the input from.
  12100. * @param element Defines the element the controls should be listened from
  12101. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12102. */
  12103. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12104. /**
  12105. * Called on JS contextmenu event.
  12106. * Override this method to provide functionality.
  12107. */
  12108. protected onContextMenu(evt: PointerEvent): void;
  12109. /**
  12110. * Detach the current controls from the specified dom element.
  12111. * @param element Defines the element to stop listening the inputs from
  12112. */
  12113. detachControl(element: Nullable<HTMLElement>): void;
  12114. /**
  12115. * Gets the class name of the current intput.
  12116. * @returns the class name
  12117. */
  12118. getClassName(): string;
  12119. /**
  12120. * Get the friendly name associated with the input class.
  12121. * @returns the input friendly name
  12122. */
  12123. getSimpleName(): string;
  12124. }
  12125. }
  12126. declare module BABYLON {
  12127. /**
  12128. * Manage the touch inputs to control the movement of a free camera.
  12129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12130. */
  12131. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12132. /**
  12133. * Defines the camera the input is attached to.
  12134. */
  12135. camera: FreeCamera;
  12136. /**
  12137. * Defines the touch sensibility for rotation.
  12138. * The higher the faster.
  12139. */
  12140. touchAngularSensibility: number;
  12141. /**
  12142. * Defines the touch sensibility for move.
  12143. * The higher the faster.
  12144. */
  12145. touchMoveSensibility: number;
  12146. private _offsetX;
  12147. private _offsetY;
  12148. private _pointerPressed;
  12149. private _pointerInput;
  12150. private _observer;
  12151. private _onLostFocus;
  12152. /**
  12153. * Attach the input controls to a specific dom element to get the input from.
  12154. * @param element Defines the element the controls should be listened from
  12155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12156. */
  12157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12158. /**
  12159. * Detach the current controls from the specified dom element.
  12160. * @param element Defines the element to stop listening the inputs from
  12161. */
  12162. detachControl(element: Nullable<HTMLElement>): void;
  12163. /**
  12164. * Update the current camera state depending on the inputs that have been used this frame.
  12165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12166. */
  12167. checkInputs(): void;
  12168. /**
  12169. * Gets the class name of the current intput.
  12170. * @returns the class name
  12171. */
  12172. getClassName(): string;
  12173. /**
  12174. * Get the friendly name associated with the input class.
  12175. * @returns the input friendly name
  12176. */
  12177. getSimpleName(): string;
  12178. }
  12179. }
  12180. declare module BABYLON {
  12181. /**
  12182. * Default Inputs manager for the FreeCamera.
  12183. * It groups all the default supported inputs for ease of use.
  12184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12185. */
  12186. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12187. /**
  12188. * @hidden
  12189. */ keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12190. /**
  12191. * @hidden
  12192. */ mouseInput: Nullable<FreeCameraMouseInput>;
  12193. /**
  12194. * Instantiates a new FreeCameraInputsManager.
  12195. * @param camera Defines the camera the inputs belong to
  12196. */
  12197. constructor(camera: FreeCamera);
  12198. /**
  12199. * Add keyboard input support to the input manager.
  12200. * @returns the current input manager
  12201. */
  12202. addKeyboard(): FreeCameraInputsManager;
  12203. /**
  12204. * Add mouse input support to the input manager.
  12205. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12206. * @returns the current input manager
  12207. */
  12208. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12209. /**
  12210. * Removes the mouse input support from the manager
  12211. * @returns the current input manager
  12212. */
  12213. removeMouse(): FreeCameraInputsManager;
  12214. /**
  12215. * Add touch input support to the input manager.
  12216. * @returns the current input manager
  12217. */
  12218. addTouch(): FreeCameraInputsManager;
  12219. }
  12220. }
  12221. declare module BABYLON {
  12222. /**
  12223. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12224. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12225. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12226. */
  12227. export class FreeCamera extends TargetCamera {
  12228. /**
  12229. * Define the collision ellipsoid of the camera.
  12230. * This is helpful to simulate a camera body like the player body around the camera
  12231. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12232. */
  12233. ellipsoid: Vector3;
  12234. /**
  12235. * Define an offset for the position of the ellipsoid around the camera.
  12236. * This can be helpful to determine the center of the body near the gravity center of the body
  12237. * instead of its head.
  12238. */
  12239. ellipsoidOffset: Vector3;
  12240. /**
  12241. * Enable or disable collisions of the camera with the rest of the scene objects.
  12242. */
  12243. checkCollisions: boolean;
  12244. /**
  12245. * Enable or disable gravity on the camera.
  12246. */
  12247. applyGravity: boolean;
  12248. /**
  12249. * Define the input manager associated to the camera.
  12250. */
  12251. inputs: FreeCameraInputsManager;
  12252. /**
  12253. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12254. * Higher values reduce sensitivity.
  12255. */
  12256. /**
  12257. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12258. * Higher values reduce sensitivity.
  12259. */
  12260. angularSensibility: number;
  12261. /**
  12262. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12263. */
  12264. keysUp: number[];
  12265. /**
  12266. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12267. */
  12268. keysDown: number[];
  12269. /**
  12270. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12271. */
  12272. keysLeft: number[];
  12273. /**
  12274. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12275. */
  12276. keysRight: number[];
  12277. /**
  12278. * Event raised when the camera collide with a mesh in the scene.
  12279. */
  12280. onCollide: (collidedMesh: AbstractMesh) => void;
  12281. private _collider;
  12282. private _needMoveForGravity;
  12283. private _oldPosition;
  12284. private _diffPosition;
  12285. private _newPosition;
  12286. /** @hidden */ localDirection: Vector3;
  12287. /** @hidden */ transformedDirection: Vector3;
  12288. /**
  12289. * Instantiates a Free Camera.
  12290. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12291. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12292. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12293. * @param name Define the name of the camera in the scene
  12294. * @param position Define the start position of the camera in the scene
  12295. * @param scene Define the scene the camera belongs to
  12296. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12297. */
  12298. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12299. /**
  12300. * Attached controls to the current camera.
  12301. * @param element Defines the element the controls should be listened from
  12302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12303. */
  12304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12305. /**
  12306. * Detach the current controls from the camera.
  12307. * The camera will stop reacting to inputs.
  12308. * @param element Defines the element to stop listening the inputs from
  12309. */
  12310. detachControl(element: HTMLElement): void;
  12311. private _collisionMask;
  12312. /**
  12313. * Define a collision mask to limit the list of object the camera can collide with
  12314. */
  12315. collisionMask: number;
  12316. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  12317. private _onCollisionPositionChange;
  12318. /** @hidden */ checkInputs(): void;
  12319. /** @hidden */ decideIfNeedsToMove(): boolean;
  12320. /** @hidden */ updatePosition(): void;
  12321. /**
  12322. * Destroy the camera and release the current resources hold by it.
  12323. */
  12324. dispose(): void;
  12325. /**
  12326. * Gets the current object class name.
  12327. * @return the class name
  12328. */
  12329. getClassName(): string;
  12330. }
  12331. }
  12332. declare module BABYLON {
  12333. /**
  12334. * Represents a gamepad control stick position
  12335. */
  12336. export class StickValues {
  12337. /**
  12338. * The x component of the control stick
  12339. */
  12340. x: number;
  12341. /**
  12342. * The y component of the control stick
  12343. */
  12344. y: number;
  12345. /**
  12346. * Initializes the gamepad x and y control stick values
  12347. * @param x The x component of the gamepad control stick value
  12348. * @param y The y component of the gamepad control stick value
  12349. */
  12350. constructor(
  12351. /**
  12352. * The x component of the control stick
  12353. */
  12354. x: number,
  12355. /**
  12356. * The y component of the control stick
  12357. */
  12358. y: number);
  12359. }
  12360. /**
  12361. * An interface which manages callbacks for gamepad button changes
  12362. */
  12363. export interface GamepadButtonChanges {
  12364. /**
  12365. * Called when a gamepad has been changed
  12366. */
  12367. changed: boolean;
  12368. /**
  12369. * Called when a gamepad press event has been triggered
  12370. */
  12371. pressChanged: boolean;
  12372. /**
  12373. * Called when a touch event has been triggered
  12374. */
  12375. touchChanged: boolean;
  12376. /**
  12377. * Called when a value has changed
  12378. */
  12379. valueChanged: boolean;
  12380. }
  12381. /**
  12382. * Represents a gamepad
  12383. */
  12384. export class Gamepad {
  12385. /**
  12386. * The id of the gamepad
  12387. */
  12388. id: string;
  12389. /**
  12390. * The index of the gamepad
  12391. */
  12392. index: number;
  12393. /**
  12394. * The browser gamepad
  12395. */
  12396. browserGamepad: any;
  12397. /**
  12398. * Specifies what type of gamepad this represents
  12399. */
  12400. type: number;
  12401. private _leftStick;
  12402. private _rightStick;
  12403. /** @hidden */ isConnected: boolean;
  12404. private _leftStickAxisX;
  12405. private _leftStickAxisY;
  12406. private _rightStickAxisX;
  12407. private _rightStickAxisY;
  12408. /**
  12409. * Triggered when the left control stick has been changed
  12410. */
  12411. private _onleftstickchanged;
  12412. /**
  12413. * Triggered when the right control stick has been changed
  12414. */
  12415. private _onrightstickchanged;
  12416. /**
  12417. * Represents a gamepad controller
  12418. */
  12419. static GAMEPAD: number;
  12420. /**
  12421. * Represents a generic controller
  12422. */
  12423. static GENERIC: number;
  12424. /**
  12425. * Represents an XBox controller
  12426. */
  12427. static XBOX: number;
  12428. /**
  12429. * Represents a pose-enabled controller
  12430. */
  12431. static POSE_ENABLED: number;
  12432. /**
  12433. * Specifies whether the left control stick should be Y-inverted
  12434. */
  12435. protected _invertLeftStickY: boolean;
  12436. /**
  12437. * Specifies if the gamepad has been connected
  12438. */
  12439. readonly isConnected: boolean;
  12440. /**
  12441. * Initializes the gamepad
  12442. * @param id The id of the gamepad
  12443. * @param index The index of the gamepad
  12444. * @param browserGamepad The browser gamepad
  12445. * @param leftStickX The x component of the left joystick
  12446. * @param leftStickY The y component of the left joystick
  12447. * @param rightStickX The x component of the right joystick
  12448. * @param rightStickY The y component of the right joystick
  12449. */
  12450. constructor(
  12451. /**
  12452. * The id of the gamepad
  12453. */
  12454. id: string,
  12455. /**
  12456. * The index of the gamepad
  12457. */
  12458. index: number,
  12459. /**
  12460. * The browser gamepad
  12461. */
  12462. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12463. /**
  12464. * Callback triggered when the left joystick has changed
  12465. * @param callback
  12466. */
  12467. onleftstickchanged(callback: (values: StickValues) => void): void;
  12468. /**
  12469. * Callback triggered when the right joystick has changed
  12470. * @param callback
  12471. */
  12472. onrightstickchanged(callback: (values: StickValues) => void): void;
  12473. /**
  12474. * Gets the left joystick
  12475. */
  12476. /**
  12477. * Sets the left joystick values
  12478. */
  12479. leftStick: StickValues;
  12480. /**
  12481. * Gets the right joystick
  12482. */
  12483. /**
  12484. * Sets the right joystick value
  12485. */
  12486. rightStick: StickValues;
  12487. /**
  12488. * Updates the gamepad joystick positions
  12489. */
  12490. update(): void;
  12491. /**
  12492. * Disposes the gamepad
  12493. */
  12494. dispose(): void;
  12495. }
  12496. /**
  12497. * Represents a generic gamepad
  12498. */
  12499. export class GenericPad extends Gamepad {
  12500. private _buttons;
  12501. private _onbuttondown;
  12502. private _onbuttonup;
  12503. /**
  12504. * Observable triggered when a button has been pressed
  12505. */
  12506. onButtonDownObservable: Observable<number>;
  12507. /**
  12508. * Observable triggered when a button has been released
  12509. */
  12510. onButtonUpObservable: Observable<number>;
  12511. /**
  12512. * Callback triggered when a button has been pressed
  12513. * @param callback Called when a button has been pressed
  12514. */
  12515. onbuttondown(callback: (buttonPressed: number) => void): void;
  12516. /**
  12517. * Callback triggered when a button has been released
  12518. * @param callback Called when a button has been released
  12519. */
  12520. onbuttonup(callback: (buttonReleased: number) => void): void;
  12521. /**
  12522. * Initializes the generic gamepad
  12523. * @param id The id of the generic gamepad
  12524. * @param index The index of the generic gamepad
  12525. * @param browserGamepad The browser gamepad
  12526. */
  12527. constructor(id: string, index: number, browserGamepad: any);
  12528. private _setButtonValue;
  12529. /**
  12530. * Updates the generic gamepad
  12531. */
  12532. update(): void;
  12533. /**
  12534. * Disposes the generic gamepad
  12535. */
  12536. dispose(): void;
  12537. }
  12538. }
  12539. declare module BABYLON {
  12540. /**
  12541. * Defines the types of pose enabled controllers that are supported
  12542. */
  12543. export enum PoseEnabledControllerType {
  12544. /**
  12545. * HTC Vive
  12546. */
  12547. VIVE = 0,
  12548. /**
  12549. * Oculus Rift
  12550. */
  12551. OCULUS = 1,
  12552. /**
  12553. * Windows mixed reality
  12554. */
  12555. WINDOWS = 2,
  12556. /**
  12557. * Samsung gear VR
  12558. */
  12559. GEAR_VR = 3,
  12560. /**
  12561. * Google Daydream
  12562. */
  12563. DAYDREAM = 4,
  12564. /**
  12565. * Generic
  12566. */
  12567. GENERIC = 5
  12568. }
  12569. /**
  12570. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12571. */
  12572. export interface MutableGamepadButton {
  12573. /**
  12574. * Value of the button/trigger
  12575. */
  12576. value: number;
  12577. /**
  12578. * If the button/trigger is currently touched
  12579. */
  12580. touched: boolean;
  12581. /**
  12582. * If the button/trigger is currently pressed
  12583. */
  12584. pressed: boolean;
  12585. }
  12586. /**
  12587. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12588. * @hidden
  12589. */
  12590. export interface ExtendedGamepadButton extends GamepadButton {
  12591. /**
  12592. * If the button/trigger is currently pressed
  12593. */
  12594. readonly pressed: boolean;
  12595. /**
  12596. * If the button/trigger is currently touched
  12597. */
  12598. readonly touched: boolean;
  12599. /**
  12600. * Value of the button/trigger
  12601. */
  12602. readonly value: number;
  12603. }
  12604. /** @hidden */
  12605. export interface _GamePadFactory {
  12606. /**
  12607. * Returns wether or not the current gamepad can be created for this type of controller.
  12608. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12609. * @returns true if it can be created, otherwise false
  12610. */
  12611. canCreate(gamepadInfo: any): boolean;
  12612. /**
  12613. * Creates a new instance of the Gamepad.
  12614. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12615. * @returns the new gamepad instance
  12616. */
  12617. create(gamepadInfo: any): Gamepad;
  12618. }
  12619. /**
  12620. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12621. */
  12622. export class PoseEnabledControllerHelper {
  12623. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12624. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12625. /**
  12626. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12627. * @param vrGamepad the gamepad to initialized
  12628. * @returns a vr controller of the type the gamepad identified as
  12629. */
  12630. static InitiateController(vrGamepad: any): Gamepad;
  12631. }
  12632. /**
  12633. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12634. */
  12635. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12636. private _deviceRoomPosition;
  12637. private _deviceRoomRotationQuaternion;
  12638. /**
  12639. * The device position in babylon space
  12640. */
  12641. devicePosition: Vector3;
  12642. /**
  12643. * The device rotation in babylon space
  12644. */
  12645. deviceRotationQuaternion: Quaternion;
  12646. /**
  12647. * The scale factor of the device in babylon space
  12648. */
  12649. deviceScaleFactor: number;
  12650. /**
  12651. * (Likely devicePosition should be used instead) The device position in its room space
  12652. */
  12653. position: Vector3;
  12654. /**
  12655. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12656. */
  12657. rotationQuaternion: Quaternion;
  12658. /**
  12659. * The type of controller (Eg. Windows mixed reality)
  12660. */
  12661. controllerType: PoseEnabledControllerType;
  12662. protected _calculatedPosition: Vector3;
  12663. private _calculatedRotation;
  12664. /**
  12665. * The raw pose from the device
  12666. */
  12667. rawPose: DevicePose;
  12668. private _trackPosition;
  12669. private _maxRotationDistFromHeadset;
  12670. private _draggedRoomRotation;
  12671. /**
  12672. * @hidden
  12673. */ disableTrackPosition(fixedPosition: Vector3): void;
  12674. /**
  12675. * Internal, the mesh attached to the controller
  12676. * @hidden
  12677. */ mesh: Nullable<AbstractMesh>;
  12678. private _poseControlledCamera;
  12679. private _leftHandSystemQuaternion;
  12680. /**
  12681. * Internal, matrix used to convert room space to babylon space
  12682. * @hidden
  12683. */ deviceToWorld: Matrix;
  12684. /**
  12685. * Node to be used when casting a ray from the controller
  12686. * @hidden
  12687. */ pointingPoseNode: Nullable<TransformNode>;
  12688. /**
  12689. * Name of the child mesh that can be used to cast a ray from the controller
  12690. */
  12691. static readonly POINTING_POSE: string;
  12692. /**
  12693. * Creates a new PoseEnabledController from a gamepad
  12694. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12695. */
  12696. constructor(browserGamepad: any);
  12697. private _workingMatrix;
  12698. /**
  12699. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12700. */
  12701. update(): void;
  12702. /**
  12703. * Updates only the pose device and mesh without doing any button event checking
  12704. */
  12705. protected _updatePoseAndMesh(): void;
  12706. /**
  12707. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12708. * @param poseData raw pose fromthe device
  12709. */
  12710. updateFromDevice(poseData: DevicePose): void;
  12711. /**
  12712. * @hidden
  12713. */ meshAttachedObservable: Observable<AbstractMesh>;
  12714. /**
  12715. * Attaches a mesh to the controller
  12716. * @param mesh the mesh to be attached
  12717. */
  12718. attachToMesh(mesh: AbstractMesh): void;
  12719. /**
  12720. * Attaches the controllers mesh to a camera
  12721. * @param camera the camera the mesh should be attached to
  12722. */
  12723. attachToPoseControlledCamera(camera: TargetCamera): void;
  12724. /**
  12725. * Disposes of the controller
  12726. */
  12727. dispose(): void;
  12728. /**
  12729. * The mesh that is attached to the controller
  12730. */
  12731. readonly mesh: Nullable<AbstractMesh>;
  12732. /**
  12733. * Gets the ray of the controller in the direction the controller is pointing
  12734. * @param length the length the resulting ray should be
  12735. * @returns a ray in the direction the controller is pointing
  12736. */
  12737. getForwardRay(length?: number): Ray;
  12738. }
  12739. }
  12740. declare module BABYLON {
  12741. /**
  12742. * Defines the WebVRController object that represents controllers tracked in 3D space
  12743. */
  12744. export abstract class WebVRController extends PoseEnabledController {
  12745. /**
  12746. * Internal, the default controller model for the controller
  12747. */
  12748. protected _defaultModel: AbstractMesh;
  12749. /**
  12750. * Fired when the trigger state has changed
  12751. */
  12752. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12753. /**
  12754. * Fired when the main button state has changed
  12755. */
  12756. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12757. /**
  12758. * Fired when the secondary button state has changed
  12759. */
  12760. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12761. /**
  12762. * Fired when the pad state has changed
  12763. */
  12764. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12765. /**
  12766. * Fired when controllers stick values have changed
  12767. */
  12768. onPadValuesChangedObservable: Observable<StickValues>;
  12769. /**
  12770. * Array of button availible on the controller
  12771. */
  12772. protected _buttons: Array<MutableGamepadButton>;
  12773. private _onButtonStateChange;
  12774. /**
  12775. * Fired when a controller button's state has changed
  12776. * @param callback the callback containing the button that was modified
  12777. */
  12778. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12779. /**
  12780. * X and Y axis corrisponding to the controllers joystick
  12781. */
  12782. pad: StickValues;
  12783. /**
  12784. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12785. */
  12786. hand: string;
  12787. /**
  12788. * The default controller model for the controller
  12789. */
  12790. readonly defaultModel: AbstractMesh;
  12791. /**
  12792. * Creates a new WebVRController from a gamepad
  12793. * @param vrGamepad the gamepad that the WebVRController should be created from
  12794. */
  12795. constructor(vrGamepad: any);
  12796. /**
  12797. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12798. */
  12799. update(): void;
  12800. /**
  12801. * Function to be called when a button is modified
  12802. */
  12803. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12804. /**
  12805. * Loads a mesh and attaches it to the controller
  12806. * @param scene the scene the mesh should be added to
  12807. * @param meshLoaded callback for when the mesh has been loaded
  12808. */
  12809. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12810. private _setButtonValue;
  12811. private _changes;
  12812. private _checkChanges;
  12813. /**
  12814. * Disposes of th webVRCOntroller
  12815. */
  12816. dispose(): void;
  12817. }
  12818. }
  12819. declare module BABYLON {
  12820. /**
  12821. * The HemisphericLight simulates the ambient environment light,
  12822. * so the passed direction is the light reflection direction, not the incoming direction.
  12823. */
  12824. export class HemisphericLight extends Light {
  12825. /**
  12826. * The groundColor is the light in the opposite direction to the one specified during creation.
  12827. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  12828. */
  12829. groundColor: Color3;
  12830. /**
  12831. * The light reflection direction, not the incoming direction.
  12832. */
  12833. direction: Vector3;
  12834. /**
  12835. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12836. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12837. * The HemisphericLight can't cast shadows.
  12838. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12839. * @param name The friendly name of the light
  12840. * @param direction The direction of the light reflection
  12841. * @param scene The scene the light belongs to
  12842. */
  12843. constructor(name: string, direction: Vector3, scene: Scene);
  12844. protected _buildUniformLayout(): void;
  12845. /**
  12846. * Returns the string "HemisphericLight".
  12847. * @return The class name
  12848. */
  12849. getClassName(): string;
  12850. /**
  12851. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12852. * Returns the updated direction.
  12853. * @param target The target the direction should point to
  12854. * @return The computed direction
  12855. */
  12856. setDirectionToTarget(target: Vector3): Vector3;
  12857. /**
  12858. * Returns the shadow generator associated to the light.
  12859. * @returns Always null for hemispheric lights because it does not support shadows.
  12860. */
  12861. getShadowGenerator(): Nullable<IShadowGenerator>;
  12862. /**
  12863. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12864. * @param effect The effect to update
  12865. * @param lightIndex The index of the light in the effect to update
  12866. * @returns The hemispheric light
  12867. */
  12868. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12869. /**
  12870. * Computes the world matrix of the node
  12871. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12872. * @param useWasUpdatedFlag defines a reserved property
  12873. * @returns the world matrix
  12874. */
  12875. computeWorldMatrix(): Matrix;
  12876. /**
  12877. * Returns the integer 3.
  12878. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12879. */
  12880. getTypeID(): number;
  12881. /**
  12882. * Prepares the list of defines specific to the light type.
  12883. * @param defines the list of defines
  12884. * @param lightIndex defines the index of the light for the effect
  12885. */
  12886. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12887. }
  12888. }
  12889. declare module BABYLON {
  12890. /** @hidden */
  12891. export var vrMultiviewToSingleviewPixelShader: {
  12892. name: string;
  12893. shader: string;
  12894. };
  12895. }
  12896. declare module BABYLON {
  12897. /**
  12898. * Renders to multiple views with a single draw call
  12899. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12900. */
  12901. export class MultiviewRenderTarget extends RenderTargetTexture {
  12902. /**
  12903. * Creates a multiview render target
  12904. * @param scene scene used with the render target
  12905. * @param size the size of the render target (used for each view)
  12906. */
  12907. constructor(scene: Scene, size?: number | {
  12908. width: number;
  12909. height: number;
  12910. } | {
  12911. ratio: number;
  12912. });
  12913. /**
  12914. * @hidden
  12915. * @param faceIndex the face index, if its a cube texture
  12916. */ bindFrameBuffer(faceIndex?: number): void;
  12917. /**
  12918. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12919. * @returns the view count
  12920. */
  12921. getViewCount(): number;
  12922. }
  12923. }
  12924. declare module BABYLON {
  12925. interface Engine {
  12926. /**
  12927. * Creates a new multiview render target
  12928. * @param width defines the width of the texture
  12929. * @param height defines the height of the texture
  12930. * @returns the created multiview texture
  12931. */
  12932. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12933. /**
  12934. * Binds a multiview framebuffer to be drawn to
  12935. * @param multiviewTexture texture to bind
  12936. */
  12937. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12938. }
  12939. interface Camera {
  12940. /**
  12941. * @hidden
  12942. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  12943. */ useMultiviewToSingleView: boolean;
  12944. /**
  12945. * @hidden
  12946. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  12947. */ multiviewTexture: Nullable<RenderTargetTexture>;
  12948. /**
  12949. * @hidden
  12950. * ensures the multiview texture of the camera exists and has the specified width/height
  12951. * @param width height to set on the multiview texture
  12952. * @param height width to set on the multiview texture
  12953. */ resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12954. }
  12955. interface Scene {
  12956. /** @hidden */ transformMatrixR: Matrix;
  12957. /** @hidden */ multiviewSceneUbo: Nullable<UniformBuffer>;
  12958. /** @hidden */ createMultiviewUbo(): void;
  12959. /** @hidden */ updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12960. /** @hidden */ renderMultiviewToSingleView(camera: Camera): void;
  12961. }
  12962. }
  12963. declare module BABYLON {
  12964. /**
  12965. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  12966. * This will not be used for webXR as it supports displaying texture arrays directly
  12967. */
  12968. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  12969. /**
  12970. * Initializes a VRMultiviewToSingleview
  12971. * @param name name of the post process
  12972. * @param camera camera to be applied to
  12973. * @param scaleFactor scaling factor to the size of the output texture
  12974. */
  12975. constructor(name: string, camera: Camera, scaleFactor: number);
  12976. }
  12977. }
  12978. declare module BABYLON {
  12979. /**
  12980. * Defines the interface used by display changed events
  12981. */
  12982. interface IDisplayChangedEventArgs {
  12983. /** Gets the vrDisplay object (if any) */
  12984. vrDisplay: Nullable<any>;
  12985. /** Gets a boolean indicating if webVR is supported */
  12986. vrSupported: boolean;
  12987. }
  12988. interface Engine {
  12989. /** @hidden */ vrDisplay: any;
  12990. /** @hidden */ vrSupported: boolean;
  12991. /** @hidden */ oldSize: Size;
  12992. /** @hidden */ oldHardwareScaleFactor: number;
  12993. /** @hidden */ vrExclusivePointerMode: boolean;
  12994. /** @hidden */ webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  12995. /** @hidden */ onVRDisplayPointerRestricted: () => void;
  12996. /** @hidden */ onVRDisplayPointerUnrestricted: () => void;
  12997. /** @hidden */ onVrDisplayConnect: Nullable<(display: any) => void>;
  12998. /** @hidden */ onVrDisplayDisconnect: Nullable<() => void>;
  12999. /** @hidden */ onVrDisplayPresentChange: Nullable<() => void>;
  13000. /**
  13001. * Observable signaled when VR display mode changes
  13002. */
  13003. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13004. /**
  13005. * Observable signaled when VR request present is complete
  13006. */
  13007. onVRRequestPresentComplete: Observable<boolean>;
  13008. /**
  13009. * Observable signaled when VR request present starts
  13010. */
  13011. onVRRequestPresentStart: Observable<Engine>;
  13012. /**
  13013. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13014. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13015. */
  13016. isInVRExclusivePointerMode: boolean;
  13017. /**
  13018. * Gets a boolean indicating if a webVR device was detected
  13019. * @returns true if a webVR device was detected
  13020. */
  13021. isVRDevicePresent(): boolean;
  13022. /**
  13023. * Gets the current webVR device
  13024. * @returns the current webVR device (or null)
  13025. */
  13026. getVRDevice(): any;
  13027. /**
  13028. * Initializes a webVR display and starts listening to display change events
  13029. * The onVRDisplayChangedObservable will be notified upon these changes
  13030. * @returns A promise containing a VRDisplay and if vr is supported
  13031. */
  13032. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13033. /** @hidden */ getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13034. /**
  13035. * Call this function to switch to webVR mode
  13036. * Will do nothing if webVR is not supported or if there is no webVR device
  13037. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13038. */
  13039. enableVR(): void;
  13040. /** @hidden */ onVRFullScreenTriggered(): void;
  13041. }
  13042. }
  13043. declare module BABYLON {
  13044. /**
  13045. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13046. * IMPORTANT!! The data is right-hand data.
  13047. * @export
  13048. * @interface DevicePose
  13049. */
  13050. export interface DevicePose {
  13051. /**
  13052. * The position of the device, values in array are [x,y,z].
  13053. */
  13054. readonly position: Nullable<Float32Array>;
  13055. /**
  13056. * The linearVelocity of the device, values in array are [x,y,z].
  13057. */
  13058. readonly linearVelocity: Nullable<Float32Array>;
  13059. /**
  13060. * The linearAcceleration of the device, values in array are [x,y,z].
  13061. */
  13062. readonly linearAcceleration: Nullable<Float32Array>;
  13063. /**
  13064. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13065. */
  13066. readonly orientation: Nullable<Float32Array>;
  13067. /**
  13068. * The angularVelocity of the device, values in array are [x,y,z].
  13069. */
  13070. readonly angularVelocity: Nullable<Float32Array>;
  13071. /**
  13072. * The angularAcceleration of the device, values in array are [x,y,z].
  13073. */
  13074. readonly angularAcceleration: Nullable<Float32Array>;
  13075. }
  13076. /**
  13077. * Interface representing a pose controlled object in Babylon.
  13078. * A pose controlled object has both regular pose values as well as pose values
  13079. * from an external device such as a VR head mounted display
  13080. */
  13081. export interface PoseControlled {
  13082. /**
  13083. * The position of the object in babylon space.
  13084. */
  13085. position: Vector3;
  13086. /**
  13087. * The rotation quaternion of the object in babylon space.
  13088. */
  13089. rotationQuaternion: Quaternion;
  13090. /**
  13091. * The position of the device in babylon space.
  13092. */
  13093. devicePosition?: Vector3;
  13094. /**
  13095. * The rotation quaternion of the device in babylon space.
  13096. */
  13097. deviceRotationQuaternion: Quaternion;
  13098. /**
  13099. * The raw pose coming from the device.
  13100. */
  13101. rawPose: Nullable<DevicePose>;
  13102. /**
  13103. * The scale of the device to be used when translating from device space to babylon space.
  13104. */
  13105. deviceScaleFactor: number;
  13106. /**
  13107. * Updates the poseControlled values based on the input device pose.
  13108. * @param poseData the pose data to update the object with
  13109. */
  13110. updateFromDevice(poseData: DevicePose): void;
  13111. }
  13112. /**
  13113. * Set of options to customize the webVRCamera
  13114. */
  13115. export interface WebVROptions {
  13116. /**
  13117. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13118. */
  13119. trackPosition?: boolean;
  13120. /**
  13121. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13122. */
  13123. positionScale?: number;
  13124. /**
  13125. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13126. */
  13127. displayName?: string;
  13128. /**
  13129. * Should the native controller meshes be initialized. (default: true)
  13130. */
  13131. controllerMeshes?: boolean;
  13132. /**
  13133. * Creating a default HemiLight only on controllers. (default: true)
  13134. */
  13135. defaultLightingOnControllers?: boolean;
  13136. /**
  13137. * If you don't want to use the default VR button of the helper. (default: false)
  13138. */
  13139. useCustomVRButton?: boolean;
  13140. /**
  13141. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13142. */
  13143. customVRButton?: HTMLButtonElement;
  13144. /**
  13145. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13146. */
  13147. rayLength?: number;
  13148. /**
  13149. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13150. */
  13151. defaultHeight?: number;
  13152. /**
  13153. * If multiview should be used if availible (default: false)
  13154. */
  13155. useMultiview?: boolean;
  13156. }
  13157. /**
  13158. * This represents a WebVR camera.
  13159. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13160. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13161. */
  13162. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13163. private webVROptions;
  13164. /**
  13165. * @hidden
  13166. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13167. */ vrDevice: any;
  13168. /**
  13169. * The rawPose of the vrDevice.
  13170. */
  13171. rawPose: Nullable<DevicePose>;
  13172. private _onVREnabled;
  13173. private _specsVersion;
  13174. private _attached;
  13175. private _frameData;
  13176. protected _descendants: Array<Node>;
  13177. private _deviceRoomPosition;
  13178. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  13179. private _standingMatrix;
  13180. /**
  13181. * Represents device position in babylon space.
  13182. */
  13183. devicePosition: Vector3;
  13184. /**
  13185. * Represents device rotation in babylon space.
  13186. */
  13187. deviceRotationQuaternion: Quaternion;
  13188. /**
  13189. * The scale of the device to be used when translating from device space to babylon space.
  13190. */
  13191. deviceScaleFactor: number;
  13192. private _deviceToWorld;
  13193. private _worldToDevice;
  13194. /**
  13195. * References to the webVR controllers for the vrDevice.
  13196. */
  13197. controllers: Array<WebVRController>;
  13198. /**
  13199. * Emits an event when a controller is attached.
  13200. */
  13201. onControllersAttachedObservable: Observable<WebVRController[]>;
  13202. /**
  13203. * Emits an event when a controller's mesh has been loaded;
  13204. */
  13205. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13206. /**
  13207. * Emits an event when the HMD's pose has been updated.
  13208. */
  13209. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13210. private _poseSet;
  13211. /**
  13212. * If the rig cameras be used as parent instead of this camera.
  13213. */
  13214. rigParenting: boolean;
  13215. private _lightOnControllers;
  13216. private _defaultHeight?;
  13217. /**
  13218. * Instantiates a WebVRFreeCamera.
  13219. * @param name The name of the WebVRFreeCamera
  13220. * @param position The starting anchor position for the camera
  13221. * @param scene The scene the camera belongs to
  13222. * @param webVROptions a set of customizable options for the webVRCamera
  13223. */
  13224. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13225. /**
  13226. * Gets the device distance from the ground in meters.
  13227. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  13228. */
  13229. deviceDistanceToRoomGround(): number;
  13230. /**
  13231. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13232. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13233. */
  13234. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13235. /**
  13236. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13237. * @returns A promise with a boolean set to if the standing matrix is supported.
  13238. */
  13239. useStandingMatrixAsync(): Promise<boolean>;
  13240. /**
  13241. * Disposes the camera
  13242. */
  13243. dispose(): void;
  13244. /**
  13245. * Gets a vrController by name.
  13246. * @param name The name of the controller to retreive
  13247. * @returns the controller matching the name specified or null if not found
  13248. */
  13249. getControllerByName(name: string): Nullable<WebVRController>;
  13250. private _leftController;
  13251. /**
  13252. * The controller corrisponding to the users left hand.
  13253. */
  13254. readonly leftController: Nullable<WebVRController>;
  13255. private _rightController;
  13256. /**
  13257. * The controller corrisponding to the users right hand.
  13258. */
  13259. readonly rightController: Nullable<WebVRController>;
  13260. /**
  13261. * Casts a ray forward from the vrCamera's gaze.
  13262. * @param length Length of the ray (default: 100)
  13263. * @returns the ray corrisponding to the gaze
  13264. */
  13265. getForwardRay(length?: number): Ray;
  13266. /**
  13267. * @hidden
  13268. * Updates the camera based on device's frame data
  13269. */ checkInputs(): void;
  13270. /**
  13271. * Updates the poseControlled values based on the input device pose.
  13272. * @param poseData Pose coming from the device
  13273. */
  13274. updateFromDevice(poseData: DevicePose): void;
  13275. private _htmlElementAttached;
  13276. private _detachIfAttached;
  13277. /**
  13278. * WebVR's attach control will start broadcasting frames to the device.
  13279. * Note that in certain browsers (chrome for example) this function must be called
  13280. * within a user-interaction callback. Example:
  13281. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13282. *
  13283. * @param element html element to attach the vrDevice to
  13284. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13285. */
  13286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13287. /**
  13288. * Detaches the camera from the html element and disables VR
  13289. *
  13290. * @param element html element to detach from
  13291. */
  13292. detachControl(element: HTMLElement): void;
  13293. /**
  13294. * @returns the name of this class
  13295. */
  13296. getClassName(): string;
  13297. /**
  13298. * Calls resetPose on the vrDisplay
  13299. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13300. */
  13301. resetToCurrentRotation(): void;
  13302. /**
  13303. * @hidden
  13304. * Updates the rig cameras (left and right eye)
  13305. */ updateRigCameras(): void;
  13306. private _workingVector;
  13307. private _oneVector;
  13308. private _workingMatrix;
  13309. private updateCacheCalled;
  13310. private _correctPositionIfNotTrackPosition;
  13311. /**
  13312. * @hidden
  13313. * Updates the cached values of the camera
  13314. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13315. */ updateCache(ignoreParentClass?: boolean): void;
  13316. /**
  13317. * @hidden
  13318. * Get current device position in babylon world
  13319. */ computeDevicePosition(): void;
  13320. /**
  13321. * Updates the current device position and rotation in the babylon world
  13322. */
  13323. update(): void;
  13324. /**
  13325. * @hidden
  13326. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13327. * @returns an identity matrix
  13328. */ getViewMatrix(): Matrix;
  13329. private _tmpMatrix;
  13330. /**
  13331. * This function is called by the two RIG cameras.
  13332. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13333. * @hidden
  13334. */ getWebVRViewMatrix(): Matrix;
  13335. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  13336. private _onGamepadConnectedObserver;
  13337. private _onGamepadDisconnectedObserver;
  13338. private _updateCacheWhenTrackingDisabledObserver;
  13339. /**
  13340. * Initializes the controllers and their meshes
  13341. */
  13342. initControllers(): void;
  13343. }
  13344. }
  13345. declare module BABYLON {
  13346. /**
  13347. * Size options for a post process
  13348. */
  13349. export type PostProcessOptions = {
  13350. width: number;
  13351. height: number;
  13352. };
  13353. /**
  13354. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13355. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13356. */
  13357. export class PostProcess {
  13358. /** Name of the PostProcess. */
  13359. name: string;
  13360. /**
  13361. * Gets or sets the unique id of the post process
  13362. */
  13363. uniqueId: number;
  13364. /**
  13365. * Width of the texture to apply the post process on
  13366. */
  13367. width: number;
  13368. /**
  13369. * Height of the texture to apply the post process on
  13370. */
  13371. height: number;
  13372. /**
  13373. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13374. * @hidden
  13375. */ outputTexture: Nullable<InternalTexture>;
  13376. /**
  13377. * Sampling mode used by the shader
  13378. * See https://doc.babylonjs.com/classes/3.1/texture
  13379. */
  13380. renderTargetSamplingMode: number;
  13381. /**
  13382. * Clear color to use when screen clearing
  13383. */
  13384. clearColor: Color4;
  13385. /**
  13386. * If the buffer needs to be cleared before applying the post process. (default: true)
  13387. * Should be set to false if shader will overwrite all previous pixels.
  13388. */
  13389. autoClear: boolean;
  13390. /**
  13391. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13392. */
  13393. alphaMode: number;
  13394. /**
  13395. * Sets the setAlphaBlendConstants of the babylon engine
  13396. */
  13397. alphaConstants: Color4;
  13398. /**
  13399. * Animations to be used for the post processing
  13400. */
  13401. animations: Animation[];
  13402. /**
  13403. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13404. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13405. */
  13406. enablePixelPerfectMode: boolean;
  13407. /**
  13408. * Force the postprocess to be applied without taking in account viewport
  13409. */
  13410. forceFullscreenViewport: boolean;
  13411. /**
  13412. * List of inspectable custom properties (used by the Inspector)
  13413. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13414. */
  13415. inspectableCustomProperties: IInspectable[];
  13416. /**
  13417. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13418. *
  13419. * | Value | Type | Description |
  13420. * | ----- | ----------------------------------- | ----------- |
  13421. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13422. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13423. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13424. *
  13425. */
  13426. scaleMode: number;
  13427. /**
  13428. * Force textures to be a power of two (default: false)
  13429. */
  13430. alwaysForcePOT: boolean;
  13431. private _samples;
  13432. /**
  13433. * Number of sample textures (default: 1)
  13434. */
  13435. samples: number;
  13436. /**
  13437. * Modify the scale of the post process to be the same as the viewport (default: false)
  13438. */
  13439. adaptScaleToCurrentViewport: boolean;
  13440. private _camera;
  13441. private _scene;
  13442. private _engine;
  13443. private _options;
  13444. private _reusable;
  13445. private _textureType;
  13446. /**
  13447. * Smart array of input and output textures for the post process.
  13448. * @hidden
  13449. */ textures: SmartArray<InternalTexture>;
  13450. /**
  13451. * The index in _textures that corresponds to the output texture.
  13452. * @hidden
  13453. */ currentRenderTextureInd: number;
  13454. private _effect;
  13455. private _samplers;
  13456. private _fragmentUrl;
  13457. private _vertexUrl;
  13458. private _parameters;
  13459. private _scaleRatio;
  13460. protected _indexParameters: any;
  13461. private _shareOutputWithPostProcess;
  13462. private _texelSize;
  13463. private _forcedOutputTexture;
  13464. /**
  13465. * Returns the fragment url or shader name used in the post process.
  13466. * @returns the fragment url or name in the shader store.
  13467. */
  13468. getEffectName(): string;
  13469. /**
  13470. * An event triggered when the postprocess is activated.
  13471. */
  13472. onActivateObservable: Observable<Camera>;
  13473. private _onActivateObserver;
  13474. /**
  13475. * A function that is added to the onActivateObservable
  13476. */
  13477. onActivate: Nullable<(camera: Camera) => void>;
  13478. /**
  13479. * An event triggered when the postprocess changes its size.
  13480. */
  13481. onSizeChangedObservable: Observable<PostProcess>;
  13482. private _onSizeChangedObserver;
  13483. /**
  13484. * A function that is added to the onSizeChangedObservable
  13485. */
  13486. onSizeChanged: (postProcess: PostProcess) => void;
  13487. /**
  13488. * An event triggered when the postprocess applies its effect.
  13489. */
  13490. onApplyObservable: Observable<Effect>;
  13491. private _onApplyObserver;
  13492. /**
  13493. * A function that is added to the onApplyObservable
  13494. */
  13495. onApply: (effect: Effect) => void;
  13496. /**
  13497. * An event triggered before rendering the postprocess
  13498. */
  13499. onBeforeRenderObservable: Observable<Effect>;
  13500. private _onBeforeRenderObserver;
  13501. /**
  13502. * A function that is added to the onBeforeRenderObservable
  13503. */
  13504. onBeforeRender: (effect: Effect) => void;
  13505. /**
  13506. * An event triggered after rendering the postprocess
  13507. */
  13508. onAfterRenderObservable: Observable<Effect>;
  13509. private _onAfterRenderObserver;
  13510. /**
  13511. * A function that is added to the onAfterRenderObservable
  13512. */
  13513. onAfterRender: (efect: Effect) => void;
  13514. /**
  13515. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  13516. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13517. */
  13518. inputTexture: InternalTexture;
  13519. /**
  13520. * Gets the camera which post process is applied to.
  13521. * @returns The camera the post process is applied to.
  13522. */
  13523. getCamera(): Camera;
  13524. /**
  13525. * Gets the texel size of the postprocess.
  13526. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13527. */
  13528. readonly texelSize: Vector2;
  13529. /**
  13530. * Creates a new instance PostProcess
  13531. * @param name The name of the PostProcess.
  13532. * @param fragmentUrl The url of the fragment shader to be used.
  13533. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13534. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13535. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13536. * @param camera The camera to apply the render pass to.
  13537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13538. * @param engine The engine which the post process will be applied. (default: current engine)
  13539. * @param reusable If the post process can be reused on the same frame. (default: false)
  13540. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13541. * @param textureType Type of textures used when performing the post process. (default: 0)
  13542. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13543. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  13544. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13545. */
  13546. constructor(
  13547. /** Name of the PostProcess. */
  13548. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  13549. /**
  13550. * Gets a string idenfifying the name of the class
  13551. * @returns "PostProcess" string
  13552. */
  13553. getClassName(): string;
  13554. /**
  13555. * Gets the engine which this post process belongs to.
  13556. * @returns The engine the post process was enabled with.
  13557. */
  13558. getEngine(): Engine;
  13559. /**
  13560. * The effect that is created when initializing the post process.
  13561. * @returns The created effect corrisponding the the postprocess.
  13562. */
  13563. getEffect(): Effect;
  13564. /**
  13565. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13566. * @param postProcess The post process to share the output with.
  13567. * @returns This post process.
  13568. */
  13569. shareOutputWith(postProcess: PostProcess): PostProcess;
  13570. /**
  13571. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13572. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13573. */
  13574. useOwnOutput(): void;
  13575. /**
  13576. * Updates the effect with the current post process compile time values and recompiles the shader.
  13577. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13578. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13579. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13580. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  13581. * @param onCompiled Called when the shader has been compiled.
  13582. * @param onError Called if there is an error when compiling a shader.
  13583. */
  13584. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13585. /**
  13586. * The post process is reusable if it can be used multiple times within one frame.
  13587. * @returns If the post process is reusable
  13588. */
  13589. isReusable(): boolean;
  13590. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13591. markTextureDirty(): void;
  13592. /**
  13593. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13594. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  13595. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13596. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13597. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13598. * @returns The target texture that was bound to be written to.
  13599. */
  13600. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13601. /**
  13602. * If the post process is supported.
  13603. */
  13604. readonly isSupported: boolean;
  13605. /**
  13606. * The aspect ratio of the output texture.
  13607. */
  13608. readonly aspectRatio: number;
  13609. /**
  13610. * Get a value indicating if the post-process is ready to be used
  13611. * @returns true if the post-process is ready (shader is compiled)
  13612. */
  13613. isReady(): boolean;
  13614. /**
  13615. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13616. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13617. */
  13618. apply(): Nullable<Effect>;
  13619. private _disposeTextures;
  13620. /**
  13621. * Disposes the post process.
  13622. * @param camera The camera to dispose the post process on.
  13623. */
  13624. dispose(camera?: Camera): void;
  13625. }
  13626. }
  13627. declare module BABYLON {
  13628. /**
  13629. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13630. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13631. */
  13632. export class PostProcessManager {
  13633. private _scene;
  13634. private _indexBuffer;
  13635. private _vertexBuffers;
  13636. /**
  13637. * Creates a new instance PostProcess
  13638. * @param scene The scene that the post process is associated with.
  13639. */
  13640. constructor(scene: Scene);
  13641. private _prepareBuffers;
  13642. private _buildIndexBuffer;
  13643. /**
  13644. * Rebuilds the vertex buffers of the manager.
  13645. * @hidden
  13646. */ rebuild(): void;
  13647. /**
  13648. * Prepares a frame to be run through a post process.
  13649. * @param sourceTexture The input texture to the post procesess. (default: null)
  13650. * @param postProcesses An array of post processes to be run. (default: null)
  13651. * @returns True if the post processes were able to be run.
  13652. * @hidden
  13653. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13654. /**
  13655. * Manually render a set of post processes to a texture.
  13656. * @param postProcesses An array of post processes to be run.
  13657. * @param targetTexture The target texture to render to.
  13658. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13659. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13660. * @param lodLevel defines which lod of the texture to render to
  13661. */
  13662. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13663. /**
  13664. * Finalize the result of the output of the postprocesses.
  13665. * @param doNotPresent If true the result will not be displayed to the screen.
  13666. * @param targetTexture The target texture to render to.
  13667. * @param faceIndex The index of the face to bind the target texture to.
  13668. * @param postProcesses The array of post processes to render.
  13669. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13670. * @hidden
  13671. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13672. /**
  13673. * Disposes of the post process manager.
  13674. */
  13675. dispose(): void;
  13676. }
  13677. }
  13678. declare module BABYLON {
  13679. interface AbstractScene {
  13680. /**
  13681. * The list of layers (background and foreground) of the scene
  13682. */
  13683. layers: Array<Layer>;
  13684. }
  13685. /**
  13686. * Defines the layer scene component responsible to manage any layers
  13687. * in a given scene.
  13688. */
  13689. export class LayerSceneComponent implements ISceneComponent {
  13690. /**
  13691. * The component name helpfull to identify the component in the list of scene components.
  13692. */
  13693. readonly name: string;
  13694. /**
  13695. * The scene the component belongs to.
  13696. */
  13697. scene: Scene;
  13698. private _engine;
  13699. /**
  13700. * Creates a new instance of the component for the given scene
  13701. * @param scene Defines the scene to register the component in
  13702. */
  13703. constructor(scene: Scene);
  13704. /**
  13705. * Registers the component in a given scene
  13706. */
  13707. register(): void;
  13708. /**
  13709. * Rebuilds the elements related to this component in case of
  13710. * context lost for instance.
  13711. */
  13712. rebuild(): void;
  13713. /**
  13714. * Disposes the component and the associated ressources.
  13715. */
  13716. dispose(): void;
  13717. private _draw;
  13718. private _drawCameraPredicate;
  13719. private _drawCameraBackground;
  13720. private _drawCameraForeground;
  13721. private _drawRenderTargetPredicate;
  13722. private _drawRenderTargetBackground;
  13723. private _drawRenderTargetForeground;
  13724. }
  13725. }
  13726. declare module BABYLON {
  13727. /** @hidden */
  13728. export var layerPixelShader: {
  13729. name: string;
  13730. shader: string;
  13731. };
  13732. }
  13733. declare module BABYLON {
  13734. /** @hidden */
  13735. export var layerVertexShader: {
  13736. name: string;
  13737. shader: string;
  13738. };
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * This represents a full screen 2d layer.
  13743. * This can be useful to display a picture in the background of your scene for instance.
  13744. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13745. */
  13746. export class Layer {
  13747. /**
  13748. * Define the name of the layer.
  13749. */
  13750. name: string;
  13751. /**
  13752. * Define the texture the layer should display.
  13753. */
  13754. texture: Nullable<Texture>;
  13755. /**
  13756. * Is the layer in background or foreground.
  13757. */
  13758. isBackground: boolean;
  13759. /**
  13760. * Define the color of the layer (instead of texture).
  13761. */
  13762. color: Color4;
  13763. /**
  13764. * Define the scale of the layer in order to zoom in out of the texture.
  13765. */
  13766. scale: Vector2;
  13767. /**
  13768. * Define an offset for the layer in order to shift the texture.
  13769. */
  13770. offset: Vector2;
  13771. /**
  13772. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13773. */
  13774. alphaBlendingMode: number;
  13775. /**
  13776. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13777. * Alpha test will not mix with the background color in case of transparency.
  13778. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13779. */
  13780. alphaTest: boolean;
  13781. /**
  13782. * Define a mask to restrict the layer to only some of the scene cameras.
  13783. */
  13784. layerMask: number;
  13785. /**
  13786. * Define the list of render target the layer is visible into.
  13787. */
  13788. renderTargetTextures: RenderTargetTexture[];
  13789. /**
  13790. * Define if the layer is only used in renderTarget or if it also
  13791. * renders in the main frame buffer of the canvas.
  13792. */
  13793. renderOnlyInRenderTargetTextures: boolean;
  13794. private _scene;
  13795. private _vertexBuffers;
  13796. private _indexBuffer;
  13797. private _effect;
  13798. private _alphaTestEffect;
  13799. /**
  13800. * An event triggered when the layer is disposed.
  13801. */
  13802. onDisposeObservable: Observable<Layer>;
  13803. private _onDisposeObserver;
  13804. /**
  13805. * Back compatibility with callback before the onDisposeObservable existed.
  13806. * The set callback will be triggered when the layer has been disposed.
  13807. */
  13808. onDispose: () => void;
  13809. /**
  13810. * An event triggered before rendering the scene
  13811. */
  13812. onBeforeRenderObservable: Observable<Layer>;
  13813. private _onBeforeRenderObserver;
  13814. /**
  13815. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13816. * The set callback will be triggered just before rendering the layer.
  13817. */
  13818. onBeforeRender: () => void;
  13819. /**
  13820. * An event triggered after rendering the scene
  13821. */
  13822. onAfterRenderObservable: Observable<Layer>;
  13823. private _onAfterRenderObserver;
  13824. /**
  13825. * Back compatibility with callback before the onAfterRenderObservable existed.
  13826. * The set callback will be triggered just after rendering the layer.
  13827. */
  13828. onAfterRender: () => void;
  13829. /**
  13830. * Instantiates a new layer.
  13831. * This represents a full screen 2d layer.
  13832. * This can be useful to display a picture in the background of your scene for instance.
  13833. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13834. * @param name Define the name of the layer in the scene
  13835. * @param imgUrl Define the url of the texture to display in the layer
  13836. * @param scene Define the scene the layer belongs to
  13837. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13838. * @param color Defines a color for the layer
  13839. */
  13840. constructor(
  13841. /**
  13842. * Define the name of the layer.
  13843. */
  13844. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13845. private _createIndexBuffer;
  13846. /** @hidden */ rebuild(): void;
  13847. /**
  13848. * Renders the layer in the scene.
  13849. */
  13850. render(): void;
  13851. /**
  13852. * Disposes and releases the associated ressources.
  13853. */
  13854. dispose(): void;
  13855. }
  13856. }
  13857. declare module BABYLON {
  13858. interface AbstractScene {
  13859. /**
  13860. * The list of procedural textures added to the scene
  13861. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13862. */
  13863. proceduralTextures: Array<ProceduralTexture>;
  13864. }
  13865. /**
  13866. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13867. * in a given scene.
  13868. */
  13869. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13870. /**
  13871. * The component name helpfull to identify the component in the list of scene components.
  13872. */
  13873. readonly name: string;
  13874. /**
  13875. * The scene the component belongs to.
  13876. */
  13877. scene: Scene;
  13878. /**
  13879. * Creates a new instance of the component for the given scene
  13880. * @param scene Defines the scene to register the component in
  13881. */
  13882. constructor(scene: Scene);
  13883. /**
  13884. * Registers the component in a given scene
  13885. */
  13886. register(): void;
  13887. /**
  13888. * Rebuilds the elements related to this component in case of
  13889. * context lost for instance.
  13890. */
  13891. rebuild(): void;
  13892. /**
  13893. * Disposes the component and the associated ressources.
  13894. */
  13895. dispose(): void;
  13896. private _beforeClear;
  13897. }
  13898. }
  13899. declare module BABYLON {
  13900. interface Engine {
  13901. /**
  13902. * Creates a new render target cube texture
  13903. * @param size defines the size of the texture
  13904. * @param options defines the options used to create the texture
  13905. * @returns a new render target cube texture stored in an InternalTexture
  13906. */
  13907. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  13908. }
  13909. }
  13910. declare module BABYLON {
  13911. /** @hidden */
  13912. export var proceduralVertexShader: {
  13913. name: string;
  13914. shader: string;
  13915. };
  13916. }
  13917. declare module BABYLON {
  13918. /**
  13919. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  13920. * This is the base class of any Procedural texture and contains most of the shareable code.
  13921. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13922. */
  13923. export class ProceduralTexture extends Texture {
  13924. isCube: boolean;
  13925. /**
  13926. * Define if the texture is enabled or not (disabled texture will not render)
  13927. */
  13928. isEnabled: boolean;
  13929. /**
  13930. * Define if the texture must be cleared before rendering (default is true)
  13931. */
  13932. autoClear: boolean;
  13933. /**
  13934. * Callback called when the texture is generated
  13935. */
  13936. onGenerated: () => void;
  13937. /**
  13938. * Event raised when the texture is generated
  13939. */
  13940. onGeneratedObservable: Observable<ProceduralTexture>;
  13941. /** @hidden */ generateMipMaps: boolean;
  13942. /** @hidden **/ effect: Effect;
  13943. /** @hidden */ textures: {
  13944. [key: string]: Texture;
  13945. };
  13946. private _size;
  13947. private _currentRefreshId;
  13948. private _refreshRate;
  13949. private _vertexBuffers;
  13950. private _indexBuffer;
  13951. private _uniforms;
  13952. private _samplers;
  13953. private _fragment;
  13954. private _floats;
  13955. private _ints;
  13956. private _floatsArrays;
  13957. private _colors3;
  13958. private _colors4;
  13959. private _vectors2;
  13960. private _vectors3;
  13961. private _matrices;
  13962. private _fallbackTexture;
  13963. private _fallbackTextureUsed;
  13964. private _engine;
  13965. private _cachedDefines;
  13966. private _contentUpdateId;
  13967. private _contentData;
  13968. /**
  13969. * Instantiates a new procedural texture.
  13970. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  13971. * This is the base class of any Procedural texture and contains most of the shareable code.
  13972. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13973. * @param name Define the name of the texture
  13974. * @param size Define the size of the texture to create
  13975. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13976. * @param scene Define the scene the texture belongs to
  13977. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13978. * @param generateMipMaps Define if the texture should creates mip maps or not
  13979. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13980. */
  13981. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13982. /**
  13983. * The effect that is created when initializing the post process.
  13984. * @returns The created effect corrisponding the the postprocess.
  13985. */
  13986. getEffect(): Effect;
  13987. /**
  13988. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13989. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13990. */
  13991. getContent(): Nullable<ArrayBufferView>;
  13992. private _createIndexBuffer;
  13993. /** @hidden */ rebuild(): void;
  13994. /**
  13995. * Resets the texture in order to recreate its associated resources.
  13996. * This can be called in case of context loss
  13997. */
  13998. reset(): void;
  13999. protected _getDefines(): string;
  14000. /**
  14001. * Is the texture ready to be used ? (rendered at least once)
  14002. * @returns true if ready, otherwise, false.
  14003. */
  14004. isReady(): boolean;
  14005. /**
  14006. * Resets the refresh counter of the texture and start bak from scratch.
  14007. * Could be useful to regenerate the texture if it is setup to render only once.
  14008. */
  14009. resetRefreshCounter(): void;
  14010. /**
  14011. * Set the fragment shader to use in order to render the texture.
  14012. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14013. */
  14014. setFragment(fragment: any): void;
  14015. /**
  14016. * Define the refresh rate of the texture or the rendering frequency.
  14017. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14018. */
  14019. refreshRate: number;
  14020. /** @hidden */ shouldRender(): boolean;
  14021. /**
  14022. * Get the size the texture is rendering at.
  14023. * @returns the size (texture is always squared)
  14024. */
  14025. getRenderSize(): number;
  14026. /**
  14027. * Resize the texture to new value.
  14028. * @param size Define the new size the texture should have
  14029. * @param generateMipMaps Define whether the new texture should create mip maps
  14030. */
  14031. resize(size: number, generateMipMaps: boolean): void;
  14032. private _checkUniform;
  14033. /**
  14034. * Set a texture in the shader program used to render.
  14035. * @param name Define the name of the uniform samplers as defined in the shader
  14036. * @param texture Define the texture to bind to this sampler
  14037. * @return the texture itself allowing "fluent" like uniform updates
  14038. */
  14039. setTexture(name: string, texture: Texture): ProceduralTexture;
  14040. /**
  14041. * Set a float in the shader.
  14042. * @param name Define the name of the uniform as defined in the shader
  14043. * @param value Define the value to give to the uniform
  14044. * @return the texture itself allowing "fluent" like uniform updates
  14045. */
  14046. setFloat(name: string, value: number): ProceduralTexture;
  14047. /**
  14048. * Set a int in the shader.
  14049. * @param name Define the name of the uniform as defined in the shader
  14050. * @param value Define the value to give to the uniform
  14051. * @return the texture itself allowing "fluent" like uniform updates
  14052. */
  14053. setInt(name: string, value: number): ProceduralTexture;
  14054. /**
  14055. * Set an array of floats in the shader.
  14056. * @param name Define the name of the uniform as defined in the shader
  14057. * @param value Define the value to give to the uniform
  14058. * @return the texture itself allowing "fluent" like uniform updates
  14059. */
  14060. setFloats(name: string, value: number[]): ProceduralTexture;
  14061. /**
  14062. * Set a vec3 in the shader from a Color3.
  14063. * @param name Define the name of the uniform as defined in the shader
  14064. * @param value Define the value to give to the uniform
  14065. * @return the texture itself allowing "fluent" like uniform updates
  14066. */
  14067. setColor3(name: string, value: Color3): ProceduralTexture;
  14068. /**
  14069. * Set a vec4 in the shader from a Color4.
  14070. * @param name Define the name of the uniform as defined in the shader
  14071. * @param value Define the value to give to the uniform
  14072. * @return the texture itself allowing "fluent" like uniform updates
  14073. */
  14074. setColor4(name: string, value: Color4): ProceduralTexture;
  14075. /**
  14076. * Set a vec2 in the shader from a Vector2.
  14077. * @param name Define the name of the uniform as defined in the shader
  14078. * @param value Define the value to give to the uniform
  14079. * @return the texture itself allowing "fluent" like uniform updates
  14080. */
  14081. setVector2(name: string, value: Vector2): ProceduralTexture;
  14082. /**
  14083. * Set a vec3 in the shader from a Vector3.
  14084. * @param name Define the name of the uniform as defined in the shader
  14085. * @param value Define the value to give to the uniform
  14086. * @return the texture itself allowing "fluent" like uniform updates
  14087. */
  14088. setVector3(name: string, value: Vector3): ProceduralTexture;
  14089. /**
  14090. * Set a mat4 in the shader from a MAtrix.
  14091. * @param name Define the name of the uniform as defined in the shader
  14092. * @param value Define the value to give to the uniform
  14093. * @return the texture itself allowing "fluent" like uniform updates
  14094. */
  14095. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14096. /**
  14097. * Render the texture to its associated render target.
  14098. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14099. */
  14100. render(useCameraPostProcess?: boolean): void;
  14101. /**
  14102. * Clone the texture.
  14103. * @returns the cloned texture
  14104. */
  14105. clone(): ProceduralTexture;
  14106. /**
  14107. * Dispose the texture and release its asoociated resources.
  14108. */
  14109. dispose(): void;
  14110. }
  14111. }
  14112. declare module BABYLON {
  14113. /**
  14114. * This represents the base class for particle system in Babylon.
  14115. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14116. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14117. * @example https://doc.babylonjs.com/babylon101/particles
  14118. */
  14119. export class BaseParticleSystem {
  14120. /**
  14121. * Source color is added to the destination color without alpha affecting the result
  14122. */
  14123. static BLENDMODE_ONEONE: number;
  14124. /**
  14125. * Blend current color and particle color using particle’s alpha
  14126. */
  14127. static BLENDMODE_STANDARD: number;
  14128. /**
  14129. * Add current color and particle color multiplied by particle’s alpha
  14130. */
  14131. static BLENDMODE_ADD: number;
  14132. /**
  14133. * Multiply current color with particle color
  14134. */
  14135. static BLENDMODE_MULTIPLY: number;
  14136. /**
  14137. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14138. */
  14139. static BLENDMODE_MULTIPLYADD: number;
  14140. /**
  14141. * List of animations used by the particle system.
  14142. */
  14143. animations: Animation[];
  14144. /**
  14145. * The id of the Particle system.
  14146. */
  14147. id: string;
  14148. /**
  14149. * The friendly name of the Particle system.
  14150. */
  14151. name: string;
  14152. /**
  14153. * The rendering group used by the Particle system to chose when to render.
  14154. */
  14155. renderingGroupId: number;
  14156. /**
  14157. * The emitter represents the Mesh or position we are attaching the particle system to.
  14158. */
  14159. emitter: Nullable<AbstractMesh | Vector3>;
  14160. /**
  14161. * The maximum number of particles to emit per frame
  14162. */
  14163. emitRate: number;
  14164. /**
  14165. * If you want to launch only a few particles at once, that can be done, as well.
  14166. */
  14167. manualEmitCount: number;
  14168. /**
  14169. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14170. */
  14171. updateSpeed: number;
  14172. /**
  14173. * The amount of time the particle system is running (depends of the overall update speed).
  14174. */
  14175. targetStopDuration: number;
  14176. /**
  14177. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14178. */
  14179. disposeOnStop: boolean;
  14180. /**
  14181. * Minimum power of emitting particles.
  14182. */
  14183. minEmitPower: number;
  14184. /**
  14185. * Maximum power of emitting particles.
  14186. */
  14187. maxEmitPower: number;
  14188. /**
  14189. * Minimum life time of emitting particles.
  14190. */
  14191. minLifeTime: number;
  14192. /**
  14193. * Maximum life time of emitting particles.
  14194. */
  14195. maxLifeTime: number;
  14196. /**
  14197. * Minimum Size of emitting particles.
  14198. */
  14199. minSize: number;
  14200. /**
  14201. * Maximum Size of emitting particles.
  14202. */
  14203. maxSize: number;
  14204. /**
  14205. * Minimum scale of emitting particles on X axis.
  14206. */
  14207. minScaleX: number;
  14208. /**
  14209. * Maximum scale of emitting particles on X axis.
  14210. */
  14211. maxScaleX: number;
  14212. /**
  14213. * Minimum scale of emitting particles on Y axis.
  14214. */
  14215. minScaleY: number;
  14216. /**
  14217. * Maximum scale of emitting particles on Y axis.
  14218. */
  14219. maxScaleY: number;
  14220. /**
  14221. * Gets or sets the minimal initial rotation in radians.
  14222. */
  14223. minInitialRotation: number;
  14224. /**
  14225. * Gets or sets the maximal initial rotation in radians.
  14226. */
  14227. maxInitialRotation: number;
  14228. /**
  14229. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14230. */
  14231. minAngularSpeed: number;
  14232. /**
  14233. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14234. */
  14235. maxAngularSpeed: number;
  14236. /**
  14237. * The texture used to render each particle. (this can be a spritesheet)
  14238. */
  14239. particleTexture: Nullable<Texture>;
  14240. /**
  14241. * The layer mask we are rendering the particles through.
  14242. */
  14243. layerMask: number;
  14244. /**
  14245. * This can help using your own shader to render the particle system.
  14246. * The according effect will be created
  14247. */
  14248. customShader: any;
  14249. /**
  14250. * By default particle system starts as soon as they are created. This prevents the
  14251. * automatic start to happen and let you decide when to start emitting particles.
  14252. */
  14253. preventAutoStart: boolean;
  14254. private _noiseTexture;
  14255. /**
  14256. * Gets or sets a texture used to add random noise to particle positions
  14257. */
  14258. noiseTexture: Nullable<ProceduralTexture>;
  14259. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14260. noiseStrength: Vector3;
  14261. /**
  14262. * Callback triggered when the particle animation is ending.
  14263. */
  14264. onAnimationEnd: Nullable<() => void>;
  14265. /**
  14266. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14267. */
  14268. blendMode: number;
  14269. /**
  14270. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14271. * to override the particles.
  14272. */
  14273. forceDepthWrite: boolean;
  14274. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  14275. preWarmCycles: number;
  14276. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14277. preWarmStepOffset: number;
  14278. /**
  14279. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14280. */
  14281. spriteCellChangeSpeed: number;
  14282. /**
  14283. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14284. */
  14285. startSpriteCellID: number;
  14286. /**
  14287. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14288. */
  14289. endSpriteCellID: number;
  14290. /**
  14291. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14292. */
  14293. spriteCellWidth: number;
  14294. /**
  14295. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14296. */
  14297. spriteCellHeight: number;
  14298. /**
  14299. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14300. */
  14301. spriteRandomStartCell: boolean;
  14302. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14303. translationPivot: Vector2;
  14304. /** @hidden */
  14305. protected _isAnimationSheetEnabled: boolean;
  14306. /**
  14307. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14308. */
  14309. beginAnimationOnStart: boolean;
  14310. /**
  14311. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14312. */
  14313. beginAnimationFrom: number;
  14314. /**
  14315. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14316. */
  14317. beginAnimationTo: number;
  14318. /**
  14319. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14320. */
  14321. beginAnimationLoop: boolean;
  14322. /**
  14323. * Gets or sets a world offset applied to all particles
  14324. */
  14325. worldOffset: Vector3;
  14326. /**
  14327. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14328. */
  14329. isAnimationSheetEnabled: boolean;
  14330. /**
  14331. * Get hosting scene
  14332. * @returns the scene
  14333. */
  14334. getScene(): Scene;
  14335. /**
  14336. * You can use gravity if you want to give an orientation to your particles.
  14337. */
  14338. gravity: Vector3;
  14339. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14340. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14341. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14342. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14343. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14344. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14345. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14346. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14347. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14348. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14349. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14350. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14351. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14352. /**
  14353. * Defines the delay in milliseconds before starting the system (0 by default)
  14354. */
  14355. startDelay: number;
  14356. /**
  14357. * Gets the current list of drag gradients.
  14358. * You must use addDragGradient and removeDragGradient to udpate this list
  14359. * @returns the list of drag gradients
  14360. */
  14361. getDragGradients(): Nullable<Array<FactorGradient>>;
  14362. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14363. limitVelocityDamping: number;
  14364. /**
  14365. * Gets the current list of limit velocity gradients.
  14366. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14367. * @returns the list of limit velocity gradients
  14368. */
  14369. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14370. /**
  14371. * Gets the current list of color gradients.
  14372. * You must use addColorGradient and removeColorGradient to udpate this list
  14373. * @returns the list of color gradients
  14374. */
  14375. getColorGradients(): Nullable<Array<ColorGradient>>;
  14376. /**
  14377. * Gets the current list of size gradients.
  14378. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14379. * @returns the list of size gradients
  14380. */
  14381. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14382. /**
  14383. * Gets the current list of color remap gradients.
  14384. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14385. * @returns the list of color remap gradients
  14386. */
  14387. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14388. /**
  14389. * Gets the current list of alpha remap gradients.
  14390. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14391. * @returns the list of alpha remap gradients
  14392. */
  14393. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14394. /**
  14395. * Gets the current list of life time gradients.
  14396. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14397. * @returns the list of life time gradients
  14398. */
  14399. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14400. /**
  14401. * Gets the current list of angular speed gradients.
  14402. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14403. * @returns the list of angular speed gradients
  14404. */
  14405. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14406. /**
  14407. * Gets the current list of velocity gradients.
  14408. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14409. * @returns the list of velocity gradients
  14410. */
  14411. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14412. /**
  14413. * Gets the current list of start size gradients.
  14414. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14415. * @returns the list of start size gradients
  14416. */
  14417. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14418. /**
  14419. * Gets the current list of emit rate gradients.
  14420. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14421. * @returns the list of emit rate gradients
  14422. */
  14423. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14424. /**
  14425. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14426. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14427. */
  14428. direction1: Vector3;
  14429. /**
  14430. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14431. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14432. */
  14433. direction2: Vector3;
  14434. /**
  14435. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  14436. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14437. */
  14438. minEmitBox: Vector3;
  14439. /**
  14440. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  14441. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14442. */
  14443. maxEmitBox: Vector3;
  14444. /**
  14445. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14446. */
  14447. color1: Color4;
  14448. /**
  14449. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14450. */
  14451. color2: Color4;
  14452. /**
  14453. * Color the particle will have at the end of its lifetime
  14454. */
  14455. colorDead: Color4;
  14456. /**
  14457. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14458. */
  14459. textureMask: Color4;
  14460. /**
  14461. * The particle emitter type defines the emitter used by the particle system.
  14462. * It can be for example box, sphere, or cone...
  14463. */
  14464. particleEmitterType: IParticleEmitterType;
  14465. /** @hidden */ isSubEmitter: boolean;
  14466. /**
  14467. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14468. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14469. */
  14470. billboardMode: number;
  14471. protected _isBillboardBased: boolean;
  14472. /**
  14473. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14474. */
  14475. isBillboardBased: boolean;
  14476. /**
  14477. * The scene the particle system belongs to.
  14478. */
  14479. protected _scene: Scene;
  14480. /**
  14481. * Local cache of defines for image processing.
  14482. */
  14483. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14484. /**
  14485. * Default configuration related to image processing available in the standard Material.
  14486. */
  14487. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14488. /**
  14489. * Gets the image processing configuration used either in this material.
  14490. */
  14491. /**
  14492. * Sets the Default image processing configuration used either in the this material.
  14493. *
  14494. * If sets to null, the scene one is in use.
  14495. */
  14496. imageProcessingConfiguration: ImageProcessingConfiguration;
  14497. /**
  14498. * Attaches a new image processing configuration to the Standard Material.
  14499. * @param configuration
  14500. */
  14501. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14502. /** @hidden */
  14503. protected _reset(): void;
  14504. /** @hidden */
  14505. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14506. /**
  14507. * Instantiates a particle system.
  14508. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14509. * @param name The name of the particle system
  14510. */
  14511. constructor(name: string);
  14512. /**
  14513. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14514. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14515. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14516. * @returns the emitter
  14517. */
  14518. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14519. /**
  14520. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14521. * @param radius The radius of the hemisphere to emit from
  14522. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14523. * @returns the emitter
  14524. */
  14525. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14526. /**
  14527. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14528. * @param radius The radius of the sphere to emit from
  14529. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14530. * @returns the emitter
  14531. */
  14532. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14533. /**
  14534. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14535. * @param radius The radius of the sphere to emit from
  14536. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14537. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14538. * @returns the emitter
  14539. */
  14540. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14541. /**
  14542. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14543. * @param radius The radius of the emission cylinder
  14544. * @param height The height of the emission cylinder
  14545. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14546. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14547. * @returns the emitter
  14548. */
  14549. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14550. /**
  14551. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14552. * @param radius The radius of the cylinder to emit from
  14553. * @param height The height of the emission cylinder
  14554. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14557. * @returns the emitter
  14558. */
  14559. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14560. /**
  14561. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14562. * @param radius The radius of the cone to emit from
  14563. * @param angle The base angle of the cone
  14564. * @returns the emitter
  14565. */
  14566. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14567. /**
  14568. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14569. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14570. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14571. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14572. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14573. * @returns the emitter
  14574. */
  14575. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14576. }
  14577. }
  14578. declare module BABYLON {
  14579. /**
  14580. * Type of sub emitter
  14581. */
  14582. export enum SubEmitterType {
  14583. /**
  14584. * Attached to the particle over it's lifetime
  14585. */
  14586. ATTACHED = 0,
  14587. /**
  14588. * Created when the particle dies
  14589. */
  14590. END = 1
  14591. }
  14592. /**
  14593. * Sub emitter class used to emit particles from an existing particle
  14594. */
  14595. export class SubEmitter {
  14596. /**
  14597. * the particle system to be used by the sub emitter
  14598. */
  14599. particleSystem: ParticleSystem;
  14600. /**
  14601. * Type of the submitter (Default: END)
  14602. */
  14603. type: SubEmitterType;
  14604. /**
  14605. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  14606. * Note: This only is supported when using an emitter of type Mesh
  14607. */
  14608. inheritDirection: boolean;
  14609. /**
  14610. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14611. */
  14612. inheritedVelocityAmount: number;
  14613. /**
  14614. * Creates a sub emitter
  14615. * @param particleSystem the particle system to be used by the sub emitter
  14616. */
  14617. constructor(
  14618. /**
  14619. * the particle system to be used by the sub emitter
  14620. */
  14621. particleSystem: ParticleSystem);
  14622. /**
  14623. * Clones the sub emitter
  14624. * @returns the cloned sub emitter
  14625. */
  14626. clone(): SubEmitter;
  14627. /**
  14628. * Serialize current object to a JSON object
  14629. * @returns the serialized object
  14630. */
  14631. serialize(): any;
  14632. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14633. /**
  14634. * Creates a new SubEmitter from a serialized JSON version
  14635. * @param serializationObject defines the JSON object to read from
  14636. * @param scene defines the hosting scene
  14637. * @param rootUrl defines the rootUrl for data loading
  14638. * @returns a new SubEmitter
  14639. */
  14640. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14641. /** Release associated resources */
  14642. dispose(): void;
  14643. }
  14644. }
  14645. declare module BABYLON {
  14646. /** @hidden */
  14647. export var clipPlaneFragmentDeclaration: {
  14648. name: string;
  14649. shader: string;
  14650. };
  14651. }
  14652. declare module BABYLON {
  14653. /** @hidden */
  14654. export var imageProcessingDeclaration: {
  14655. name: string;
  14656. shader: string;
  14657. };
  14658. }
  14659. declare module BABYLON {
  14660. /** @hidden */
  14661. export var imageProcessingFunctions: {
  14662. name: string;
  14663. shader: string;
  14664. };
  14665. }
  14666. declare module BABYLON {
  14667. /** @hidden */
  14668. export var clipPlaneFragment: {
  14669. name: string;
  14670. shader: string;
  14671. };
  14672. }
  14673. declare module BABYLON {
  14674. /** @hidden */
  14675. export var particlesPixelShader: {
  14676. name: string;
  14677. shader: string;
  14678. };
  14679. }
  14680. declare module BABYLON {
  14681. /** @hidden */
  14682. export var clipPlaneVertexDeclaration: {
  14683. name: string;
  14684. shader: string;
  14685. };
  14686. }
  14687. declare module BABYLON {
  14688. /** @hidden */
  14689. export var clipPlaneVertex: {
  14690. name: string;
  14691. shader: string;
  14692. };
  14693. }
  14694. declare module BABYLON {
  14695. /** @hidden */
  14696. export var particlesVertexShader: {
  14697. name: string;
  14698. shader: string;
  14699. };
  14700. }
  14701. declare module BABYLON {
  14702. /**
  14703. * This represents a particle system in Babylon.
  14704. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14705. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14706. * @example https://doc.babylonjs.com/babylon101/particles
  14707. */
  14708. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14709. /**
  14710. * Billboard mode will only apply to Y axis
  14711. */
  14712. static readonly BILLBOARDMODE_Y: number;
  14713. /**
  14714. * Billboard mode will apply to all axes
  14715. */
  14716. static readonly BILLBOARDMODE_ALL: number;
  14717. /**
  14718. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14719. */
  14720. static readonly BILLBOARDMODE_STRETCHED: number;
  14721. /**
  14722. * This function can be defined to provide custom update for active particles.
  14723. * This function will be called instead of regular update (age, position, color, etc.).
  14724. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14725. */
  14726. updateFunction: (particles: Particle[]) => void;
  14727. private _emitterWorldMatrix;
  14728. /**
  14729. * This function can be defined to specify initial direction for every new particle.
  14730. * It by default use the emitterType defined function
  14731. */
  14732. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14733. /**
  14734. * This function can be defined to specify initial position for every new particle.
  14735. * It by default use the emitterType defined function
  14736. */
  14737. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14738. /**
  14739. * @hidden
  14740. */ inheritedVelocityOffset: Vector3;
  14741. /**
  14742. * An event triggered when the system is disposed
  14743. */
  14744. onDisposeObservable: Observable<ParticleSystem>;
  14745. private _onDisposeObserver;
  14746. /**
  14747. * Sets a callback that will be triggered when the system is disposed
  14748. */
  14749. onDispose: () => void;
  14750. private _particles;
  14751. private _epsilon;
  14752. private _capacity;
  14753. private _stockParticles;
  14754. private _newPartsExcess;
  14755. private _vertexData;
  14756. private _vertexBuffer;
  14757. private _vertexBuffers;
  14758. private _spriteBuffer;
  14759. private _indexBuffer;
  14760. private _effect;
  14761. private _customEffect;
  14762. private _cachedDefines;
  14763. private _scaledColorStep;
  14764. private _colorDiff;
  14765. private _scaledDirection;
  14766. private _scaledGravity;
  14767. private _currentRenderId;
  14768. private _alive;
  14769. private _useInstancing;
  14770. private _started;
  14771. private _stopped;
  14772. private _actualFrame;
  14773. private _scaledUpdateSpeed;
  14774. private _vertexBufferSize;
  14775. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14776. /** @hidden */ currentEmitRate1: number;
  14777. /** @hidden */ currentEmitRate2: number;
  14778. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14779. /** @hidden */ currentStartSize1: number;
  14780. /** @hidden */ currentStartSize2: number;
  14781. private readonly _rawTextureWidth;
  14782. private _rampGradientsTexture;
  14783. private _useRampGradients;
  14784. /** Gets or sets a boolean indicating that ramp gradients must be used
  14785. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14786. */
  14787. useRampGradients: boolean;
  14788. /**
  14789. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  14790. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  14791. */
  14792. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14793. private _subEmitters;
  14794. /**
  14795. * @hidden
  14796. * If the particle systems emitter should be disposed when the particle system is disposed
  14797. */ disposeEmitterOnDispose: boolean;
  14798. /**
  14799. * The current active Sub-systems, this property is used by the root particle system only.
  14800. */
  14801. activeSubSystems: Array<ParticleSystem>;
  14802. private _rootParticleSystem;
  14803. /**
  14804. * Gets the current list of active particles
  14805. */
  14806. readonly particles: Particle[];
  14807. /**
  14808. * Returns the string "ParticleSystem"
  14809. * @returns a string containing the class name
  14810. */
  14811. getClassName(): string;
  14812. /**
  14813. * Instantiates a particle system.
  14814. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14815. * @param name The name of the particle system
  14816. * @param capacity The max number of particles alive at the same time
  14817. * @param scene The scene the particle system belongs to
  14818. * @param customEffect a custom effect used to change the way particles are rendered by default
  14819. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14820. * @param epsilon Offset used to render the particles
  14821. */
  14822. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14823. private _addFactorGradient;
  14824. private _removeFactorGradient;
  14825. /**
  14826. * Adds a new life time gradient
  14827. * @param gradient defines the gradient to use (between 0 and 1)
  14828. * @param factor defines the life time factor to affect to the specified gradient
  14829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14830. * @returns the current particle system
  14831. */
  14832. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14833. /**
  14834. * Remove a specific life time gradient
  14835. * @param gradient defines the gradient to remove
  14836. * @returns the current particle system
  14837. */
  14838. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14839. /**
  14840. * Adds a new size gradient
  14841. * @param gradient defines the gradient to use (between 0 and 1)
  14842. * @param factor defines the size factor to affect to the specified gradient
  14843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14844. * @returns the current particle system
  14845. */
  14846. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14847. /**
  14848. * Remove a specific size gradient
  14849. * @param gradient defines the gradient to remove
  14850. * @returns the current particle system
  14851. */
  14852. removeSizeGradient(gradient: number): IParticleSystem;
  14853. /**
  14854. * Adds a new color remap gradient
  14855. * @param gradient defines the gradient to use (between 0 and 1)
  14856. * @param min defines the color remap minimal range
  14857. * @param max defines the color remap maximal range
  14858. * @returns the current particle system
  14859. */
  14860. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14861. /**
  14862. * Remove a specific color remap gradient
  14863. * @param gradient defines the gradient to remove
  14864. * @returns the current particle system
  14865. */
  14866. removeColorRemapGradient(gradient: number): IParticleSystem;
  14867. /**
  14868. * Adds a new alpha remap gradient
  14869. * @param gradient defines the gradient to use (between 0 and 1)
  14870. * @param min defines the alpha remap minimal range
  14871. * @param max defines the alpha remap maximal range
  14872. * @returns the current particle system
  14873. */
  14874. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14875. /**
  14876. * Remove a specific alpha remap gradient
  14877. * @param gradient defines the gradient to remove
  14878. * @returns the current particle system
  14879. */
  14880. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14881. /**
  14882. * Adds a new angular speed gradient
  14883. * @param gradient defines the gradient to use (between 0 and 1)
  14884. * @param factor defines the angular speed to affect to the specified gradient
  14885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14886. * @returns the current particle system
  14887. */
  14888. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14889. /**
  14890. * Remove a specific angular speed gradient
  14891. * @param gradient defines the gradient to remove
  14892. * @returns the current particle system
  14893. */
  14894. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14895. /**
  14896. * Adds a new velocity gradient
  14897. * @param gradient defines the gradient to use (between 0 and 1)
  14898. * @param factor defines the velocity to affect to the specified gradient
  14899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14900. * @returns the current particle system
  14901. */
  14902. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14903. /**
  14904. * Remove a specific velocity gradient
  14905. * @param gradient defines the gradient to remove
  14906. * @returns the current particle system
  14907. */
  14908. removeVelocityGradient(gradient: number): IParticleSystem;
  14909. /**
  14910. * Adds a new limit velocity gradient
  14911. * @param gradient defines the gradient to use (between 0 and 1)
  14912. * @param factor defines the limit velocity value to affect to the specified gradient
  14913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14914. * @returns the current particle system
  14915. */
  14916. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14917. /**
  14918. * Remove a specific limit velocity gradient
  14919. * @param gradient defines the gradient to remove
  14920. * @returns the current particle system
  14921. */
  14922. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14923. /**
  14924. * Adds a new drag gradient
  14925. * @param gradient defines the gradient to use (between 0 and 1)
  14926. * @param factor defines the drag value to affect to the specified gradient
  14927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14928. * @returns the current particle system
  14929. */
  14930. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14931. /**
  14932. * Remove a specific drag gradient
  14933. * @param gradient defines the gradient to remove
  14934. * @returns the current particle system
  14935. */
  14936. removeDragGradient(gradient: number): IParticleSystem;
  14937. /**
  14938. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14939. * @param gradient defines the gradient to use (between 0 and 1)
  14940. * @param factor defines the emit rate value to affect to the specified gradient
  14941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14942. * @returns the current particle system
  14943. */
  14944. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14945. /**
  14946. * Remove a specific emit rate gradient
  14947. * @param gradient defines the gradient to remove
  14948. * @returns the current particle system
  14949. */
  14950. removeEmitRateGradient(gradient: number): IParticleSystem;
  14951. /**
  14952. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14953. * @param gradient defines the gradient to use (between 0 and 1)
  14954. * @param factor defines the start size value to affect to the specified gradient
  14955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14956. * @returns the current particle system
  14957. */
  14958. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14959. /**
  14960. * Remove a specific start size gradient
  14961. * @param gradient defines the gradient to remove
  14962. * @returns the current particle system
  14963. */
  14964. removeStartSizeGradient(gradient: number): IParticleSystem;
  14965. private _createRampGradientTexture;
  14966. /**
  14967. * Gets the current list of ramp gradients.
  14968. * You must use addRampGradient and removeRampGradient to udpate this list
  14969. * @returns the list of ramp gradients
  14970. */
  14971. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14972. /**
  14973. * Adds a new ramp gradient used to remap particle colors
  14974. * @param gradient defines the gradient to use (between 0 and 1)
  14975. * @param color defines the color to affect to the specified gradient
  14976. * @returns the current particle system
  14977. */
  14978. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14979. /**
  14980. * Remove a specific ramp gradient
  14981. * @param gradient defines the gradient to remove
  14982. * @returns the current particle system
  14983. */
  14984. removeRampGradient(gradient: number): ParticleSystem;
  14985. /**
  14986. * Adds a new color gradient
  14987. * @param gradient defines the gradient to use (between 0 and 1)
  14988. * @param color1 defines the color to affect to the specified gradient
  14989. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14990. * @returns this particle system
  14991. */
  14992. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14993. /**
  14994. * Remove a specific color gradient
  14995. * @param gradient defines the gradient to remove
  14996. * @returns this particle system
  14997. */
  14998. removeColorGradient(gradient: number): IParticleSystem;
  14999. private _fetchR;
  15000. protected _reset(): void;
  15001. private _resetEffect;
  15002. private _createVertexBuffers;
  15003. private _createIndexBuffer;
  15004. /**
  15005. * Gets the maximum number of particles active at the same time.
  15006. * @returns The max number of active particles.
  15007. */
  15008. getCapacity(): number;
  15009. /**
  15010. * Gets whether there are still active particles in the system.
  15011. * @returns True if it is alive, otherwise false.
  15012. */
  15013. isAlive(): boolean;
  15014. /**
  15015. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15016. * @returns True if it has been started, otherwise false.
  15017. */
  15018. isStarted(): boolean;
  15019. private _prepareSubEmitterInternalArray;
  15020. /**
  15021. * Starts the particle system and begins to emit
  15022. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15023. */
  15024. start(delay?: number): void;
  15025. /**
  15026. * Stops the particle system.
  15027. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  15028. */
  15029. stop(stopSubEmitters?: boolean): void;
  15030. /**
  15031. * Remove all active particles
  15032. */
  15033. reset(): void;
  15034. /**
  15035. * @hidden (for internal use only)
  15036. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15037. /**
  15038. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15039. * Its lifetime will start back at 0.
  15040. */
  15041. recycleParticle: (particle: Particle) => void;
  15042. private _stopSubEmitters;
  15043. private _createParticle;
  15044. private _removeFromRoot;
  15045. private _emitFromParticle;
  15046. private _update;
  15047. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15048. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15049. /** @hidden */
  15050. private _getEffect;
  15051. /**
  15052. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15053. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15054. */
  15055. animate(preWarmOnly?: boolean): void;
  15056. private _appendParticleVertices;
  15057. /**
  15058. * Rebuilds the particle system.
  15059. */
  15060. rebuild(): void;
  15061. /**
  15062. * Is this system ready to be used/rendered
  15063. * @return true if the system is ready
  15064. */
  15065. isReady(): boolean;
  15066. private _render;
  15067. /**
  15068. * Renders the particle system in its current state.
  15069. * @returns the current number of particles
  15070. */
  15071. render(): number;
  15072. /**
  15073. * Disposes the particle system and free the associated resources
  15074. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15075. */
  15076. dispose(disposeTexture?: boolean): void;
  15077. /**
  15078. * Clones the particle system.
  15079. * @param name The name of the cloned object
  15080. * @param newEmitter The new emitter to use
  15081. * @returns the cloned particle system
  15082. */
  15083. clone(name: string, newEmitter: any): ParticleSystem;
  15084. /**
  15085. * Serializes the particle system to a JSON object.
  15086. * @returns the JSON object
  15087. */
  15088. serialize(): any;
  15089. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15090. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15091. /**
  15092. * Parses a JSON object to create a particle system.
  15093. * @param parsedParticleSystem The JSON object to parse
  15094. * @param scene The scene to create the particle system in
  15095. * @param rootUrl The root url to use to load external dependencies like texture
  15096. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15097. * @returns the Parsed particle system
  15098. */
  15099. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15100. }
  15101. }
  15102. declare module BABYLON {
  15103. /**
  15104. * A particle represents one of the element emitted by a particle system.
  15105. * This is mainly define by its coordinates, direction, velocity and age.
  15106. */
  15107. export class Particle {
  15108. /**
  15109. * The particle system the particle belongs to.
  15110. */
  15111. particleSystem: ParticleSystem;
  15112. private static _Count;
  15113. /**
  15114. * Unique ID of the particle
  15115. */
  15116. id: number;
  15117. /**
  15118. * The world position of the particle in the scene.
  15119. */
  15120. position: Vector3;
  15121. /**
  15122. * The world direction of the particle in the scene.
  15123. */
  15124. direction: Vector3;
  15125. /**
  15126. * The color of the particle.
  15127. */
  15128. color: Color4;
  15129. /**
  15130. * The color change of the particle per step.
  15131. */
  15132. colorStep: Color4;
  15133. /**
  15134. * Defines how long will the life of the particle be.
  15135. */
  15136. lifeTime: number;
  15137. /**
  15138. * The current age of the particle.
  15139. */
  15140. age: number;
  15141. /**
  15142. * The current size of the particle.
  15143. */
  15144. size: number;
  15145. /**
  15146. * The current scale of the particle.
  15147. */
  15148. scale: Vector2;
  15149. /**
  15150. * The current angle of the particle.
  15151. */
  15152. angle: number;
  15153. /**
  15154. * Defines how fast is the angle changing.
  15155. */
  15156. angularSpeed: number;
  15157. /**
  15158. * Defines the cell index used by the particle to be rendered from a sprite.
  15159. */
  15160. cellIndex: number;
  15161. /**
  15162. * The information required to support color remapping
  15163. */
  15164. remapData: Vector4;
  15165. /** @hidden */ randomCellOffset?: number;
  15166. /** @hidden */ initialDirection: Nullable<Vector3>;
  15167. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15168. /** @hidden */ initialStartSpriteCellID: number;
  15169. /** @hidden */ initialEndSpriteCellID: number;
  15170. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  15171. /** @hidden */ currentColor1: Color4;
  15172. /** @hidden */ currentColor2: Color4;
  15173. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  15174. /** @hidden */ currentSize1: number;
  15175. /** @hidden */ currentSize2: number;
  15176. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  15177. /** @hidden */ currentAngularSpeed1: number;
  15178. /** @hidden */ currentAngularSpeed2: number;
  15179. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  15180. /** @hidden */ currentVelocity1: number;
  15181. /** @hidden */ currentVelocity2: number;
  15182. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  15183. /** @hidden */ currentLimitVelocity1: number;
  15184. /** @hidden */ currentLimitVelocity2: number;
  15185. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  15186. /** @hidden */ currentDrag1: number;
  15187. /** @hidden */ currentDrag2: number;
  15188. /** @hidden */ randomNoiseCoordinates1: Vector3;
  15189. /** @hidden */ randomNoiseCoordinates2: Vector3;
  15190. /**
  15191. * Creates a new instance Particle
  15192. * @param particleSystem the particle system the particle belongs to
  15193. */
  15194. constructor(
  15195. /**
  15196. * The particle system the particle belongs to.
  15197. */
  15198. particleSystem: ParticleSystem);
  15199. private updateCellInfoFromSystem;
  15200. /**
  15201. * Defines how the sprite cell index is updated for the particle
  15202. */
  15203. updateCellIndex(): void;
  15204. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15205. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  15206. /** @hidden */ reset(): void;
  15207. /**
  15208. * Copy the properties of particle to another one.
  15209. * @param other the particle to copy the information to.
  15210. */
  15211. copyTo(other: Particle): void;
  15212. }
  15213. }
  15214. declare module BABYLON {
  15215. /**
  15216. * Particle emitter represents a volume emitting particles.
  15217. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15218. */
  15219. export interface IParticleEmitterType {
  15220. /**
  15221. * Called by the particle System when the direction is computed for the created particle.
  15222. * @param worldMatrix is the world matrix of the particle system
  15223. * @param directionToUpdate is the direction vector to update with the result
  15224. * @param particle is the particle we are computed the direction for
  15225. */
  15226. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15227. /**
  15228. * Called by the particle System when the position is computed for the created particle.
  15229. * @param worldMatrix is the world matrix of the particle system
  15230. * @param positionToUpdate is the position vector to update with the result
  15231. * @param particle is the particle we are computed the position for
  15232. */
  15233. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15234. /**
  15235. * Clones the current emitter and returns a copy of it
  15236. * @returns the new emitter
  15237. */
  15238. clone(): IParticleEmitterType;
  15239. /**
  15240. * Called by the GPUParticleSystem to setup the update shader
  15241. * @param effect defines the update shader
  15242. */
  15243. applyToShader(effect: Effect): void;
  15244. /**
  15245. * Returns a string to use to update the GPU particles update shader
  15246. * @returns the effect defines string
  15247. */
  15248. getEffectDefines(): string;
  15249. /**
  15250. * Returns a string representing the class name
  15251. * @returns a string containing the class name
  15252. */
  15253. getClassName(): string;
  15254. /**
  15255. * Serializes the particle system to a JSON object.
  15256. * @returns the JSON object
  15257. */
  15258. serialize(): any;
  15259. /**
  15260. * Parse properties from a JSON object
  15261. * @param serializationObject defines the JSON object
  15262. */
  15263. parse(serializationObject: any): void;
  15264. }
  15265. }
  15266. declare module BABYLON {
  15267. /**
  15268. * Particle emitter emitting particles from the inside of a box.
  15269. * It emits the particles randomly between 2 given directions.
  15270. */
  15271. export class BoxParticleEmitter implements IParticleEmitterType {
  15272. /**
  15273. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15274. */
  15275. direction1: Vector3;
  15276. /**
  15277. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15278. */
  15279. direction2: Vector3;
  15280. /**
  15281. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15282. */
  15283. minEmitBox: Vector3;
  15284. /**
  15285. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15286. */
  15287. maxEmitBox: Vector3;
  15288. /**
  15289. * Creates a new instance BoxParticleEmitter
  15290. */
  15291. constructor();
  15292. /**
  15293. * Called by the particle System when the direction is computed for the created particle.
  15294. * @param worldMatrix is the world matrix of the particle system
  15295. * @param directionToUpdate is the direction vector to update with the result
  15296. * @param particle is the particle we are computed the direction for
  15297. */
  15298. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15299. /**
  15300. * Called by the particle System when the position is computed for the created particle.
  15301. * @param worldMatrix is the world matrix of the particle system
  15302. * @param positionToUpdate is the position vector to update with the result
  15303. * @param particle is the particle we are computed the position for
  15304. */
  15305. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15306. /**
  15307. * Clones the current emitter and returns a copy of it
  15308. * @returns the new emitter
  15309. */
  15310. clone(): BoxParticleEmitter;
  15311. /**
  15312. * Called by the GPUParticleSystem to setup the update shader
  15313. * @param effect defines the update shader
  15314. */
  15315. applyToShader(effect: Effect): void;
  15316. /**
  15317. * Returns a string to use to update the GPU particles update shader
  15318. * @returns a string containng the defines string
  15319. */
  15320. getEffectDefines(): string;
  15321. /**
  15322. * Returns the string "BoxParticleEmitter"
  15323. * @returns a string containing the class name
  15324. */
  15325. getClassName(): string;
  15326. /**
  15327. * Serializes the particle system to a JSON object.
  15328. * @returns the JSON object
  15329. */
  15330. serialize(): any;
  15331. /**
  15332. * Parse properties from a JSON object
  15333. * @param serializationObject defines the JSON object
  15334. */
  15335. parse(serializationObject: any): void;
  15336. }
  15337. }
  15338. declare module BABYLON {
  15339. /**
  15340. * Particle emitter emitting particles from the inside of a cone.
  15341. * It emits the particles alongside the cone volume from the base to the particle.
  15342. * The emission direction might be randomized.
  15343. */
  15344. export class ConeParticleEmitter implements IParticleEmitterType {
  15345. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15346. directionRandomizer: number;
  15347. private _radius;
  15348. private _angle;
  15349. private _height;
  15350. /**
  15351. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15352. */
  15353. radiusRange: number;
  15354. /**
  15355. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15356. */
  15357. heightRange: number;
  15358. /**
  15359. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15360. */
  15361. emitFromSpawnPointOnly: boolean;
  15362. /**
  15363. * Gets or sets the radius of the emission cone
  15364. */
  15365. radius: number;
  15366. /**
  15367. * Gets or sets the angle of the emission cone
  15368. */
  15369. angle: number;
  15370. private _buildHeight;
  15371. /**
  15372. * Creates a new instance ConeParticleEmitter
  15373. * @param radius the radius of the emission cone (1 by default)
  15374. * @param angle the cone base angle (PI by default)
  15375. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15376. */
  15377. constructor(radius?: number, angle?: number,
  15378. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15379. directionRandomizer?: number);
  15380. /**
  15381. * Called by the particle System when the direction is computed for the created particle.
  15382. * @param worldMatrix is the world matrix of the particle system
  15383. * @param directionToUpdate is the direction vector to update with the result
  15384. * @param particle is the particle we are computed the direction for
  15385. */
  15386. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15387. /**
  15388. * Called by the particle System when the position is computed for the created particle.
  15389. * @param worldMatrix is the world matrix of the particle system
  15390. * @param positionToUpdate is the position vector to update with the result
  15391. * @param particle is the particle we are computed the position for
  15392. */
  15393. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15394. /**
  15395. * Clones the current emitter and returns a copy of it
  15396. * @returns the new emitter
  15397. */
  15398. clone(): ConeParticleEmitter;
  15399. /**
  15400. * Called by the GPUParticleSystem to setup the update shader
  15401. * @param effect defines the update shader
  15402. */
  15403. applyToShader(effect: Effect): void;
  15404. /**
  15405. * Returns a string to use to update the GPU particles update shader
  15406. * @returns a string containng the defines string
  15407. */
  15408. getEffectDefines(): string;
  15409. /**
  15410. * Returns the string "ConeParticleEmitter"
  15411. * @returns a string containing the class name
  15412. */
  15413. getClassName(): string;
  15414. /**
  15415. * Serializes the particle system to a JSON object.
  15416. * @returns the JSON object
  15417. */
  15418. serialize(): any;
  15419. /**
  15420. * Parse properties from a JSON object
  15421. * @param serializationObject defines the JSON object
  15422. */
  15423. parse(serializationObject: any): void;
  15424. }
  15425. }
  15426. declare module BABYLON {
  15427. /**
  15428. * Particle emitter emitting particles from the inside of a cylinder.
  15429. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15430. */
  15431. export class CylinderParticleEmitter implements IParticleEmitterType {
  15432. /**
  15433. * The radius of the emission cylinder.
  15434. */
  15435. radius: number;
  15436. /**
  15437. * The height of the emission cylinder.
  15438. */
  15439. height: number;
  15440. /**
  15441. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15442. */
  15443. radiusRange: number;
  15444. /**
  15445. * How much to randomize the particle direction [0-1].
  15446. */
  15447. directionRandomizer: number;
  15448. /**
  15449. * Creates a new instance CylinderParticleEmitter
  15450. * @param radius the radius of the emission cylinder (1 by default)
  15451. * @param height the height of the emission cylinder (1 by default)
  15452. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15453. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15454. */
  15455. constructor(
  15456. /**
  15457. * The radius of the emission cylinder.
  15458. */
  15459. radius?: number,
  15460. /**
  15461. * The height of the emission cylinder.
  15462. */
  15463. height?: number,
  15464. /**
  15465. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15466. */
  15467. radiusRange?: number,
  15468. /**
  15469. * How much to randomize the particle direction [0-1].
  15470. */
  15471. directionRandomizer?: number);
  15472. /**
  15473. * Called by the particle System when the direction is computed for the created particle.
  15474. * @param worldMatrix is the world matrix of the particle system
  15475. * @param directionToUpdate is the direction vector to update with the result
  15476. * @param particle is the particle we are computed the direction for
  15477. */
  15478. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15479. /**
  15480. * Called by the particle System when the position is computed for the created particle.
  15481. * @param worldMatrix is the world matrix of the particle system
  15482. * @param positionToUpdate is the position vector to update with the result
  15483. * @param particle is the particle we are computed the position for
  15484. */
  15485. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15486. /**
  15487. * Clones the current emitter and returns a copy of it
  15488. * @returns the new emitter
  15489. */
  15490. clone(): CylinderParticleEmitter;
  15491. /**
  15492. * Called by the GPUParticleSystem to setup the update shader
  15493. * @param effect defines the update shader
  15494. */
  15495. applyToShader(effect: Effect): void;
  15496. /**
  15497. * Returns a string to use to update the GPU particles update shader
  15498. * @returns a string containng the defines string
  15499. */
  15500. getEffectDefines(): string;
  15501. /**
  15502. * Returns the string "CylinderParticleEmitter"
  15503. * @returns a string containing the class name
  15504. */
  15505. getClassName(): string;
  15506. /**
  15507. * Serializes the particle system to a JSON object.
  15508. * @returns the JSON object
  15509. */
  15510. serialize(): any;
  15511. /**
  15512. * Parse properties from a JSON object
  15513. * @param serializationObject defines the JSON object
  15514. */
  15515. parse(serializationObject: any): void;
  15516. }
  15517. /**
  15518. * Particle emitter emitting particles from the inside of a cylinder.
  15519. * It emits the particles randomly between two vectors.
  15520. */
  15521. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15522. /**
  15523. * The min limit of the emission direction.
  15524. */
  15525. direction1: Vector3;
  15526. /**
  15527. * The max limit of the emission direction.
  15528. */
  15529. direction2: Vector3;
  15530. /**
  15531. * Creates a new instance CylinderDirectedParticleEmitter
  15532. * @param radius the radius of the emission cylinder (1 by default)
  15533. * @param height the height of the emission cylinder (1 by default)
  15534. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15535. * @param direction1 the min limit of the emission direction (up vector by default)
  15536. * @param direction2 the max limit of the emission direction (up vector by default)
  15537. */
  15538. constructor(radius?: number, height?: number, radiusRange?: number,
  15539. /**
  15540. * The min limit of the emission direction.
  15541. */
  15542. direction1?: Vector3,
  15543. /**
  15544. * The max limit of the emission direction.
  15545. */
  15546. direction2?: Vector3);
  15547. /**
  15548. * Called by the particle System when the direction is computed for the created particle.
  15549. * @param worldMatrix is the world matrix of the particle system
  15550. * @param directionToUpdate is the direction vector to update with the result
  15551. * @param particle is the particle we are computed the direction for
  15552. */
  15553. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15554. /**
  15555. * Clones the current emitter and returns a copy of it
  15556. * @returns the new emitter
  15557. */
  15558. clone(): CylinderDirectedParticleEmitter;
  15559. /**
  15560. * Called by the GPUParticleSystem to setup the update shader
  15561. * @param effect defines the update shader
  15562. */
  15563. applyToShader(effect: Effect): void;
  15564. /**
  15565. * Returns a string to use to update the GPU particles update shader
  15566. * @returns a string containng the defines string
  15567. */
  15568. getEffectDefines(): string;
  15569. /**
  15570. * Returns the string "CylinderDirectedParticleEmitter"
  15571. * @returns a string containing the class name
  15572. */
  15573. getClassName(): string;
  15574. /**
  15575. * Serializes the particle system to a JSON object.
  15576. * @returns the JSON object
  15577. */
  15578. serialize(): any;
  15579. /**
  15580. * Parse properties from a JSON object
  15581. * @param serializationObject defines the JSON object
  15582. */
  15583. parse(serializationObject: any): void;
  15584. }
  15585. }
  15586. declare module BABYLON {
  15587. /**
  15588. * Particle emitter emitting particles from the inside of a hemisphere.
  15589. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15590. */
  15591. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15592. /**
  15593. * The radius of the emission hemisphere.
  15594. */
  15595. radius: number;
  15596. /**
  15597. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15598. */
  15599. radiusRange: number;
  15600. /**
  15601. * How much to randomize the particle direction [0-1].
  15602. */
  15603. directionRandomizer: number;
  15604. /**
  15605. * Creates a new instance HemisphericParticleEmitter
  15606. * @param radius the radius of the emission hemisphere (1 by default)
  15607. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15608. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15609. */
  15610. constructor(
  15611. /**
  15612. * The radius of the emission hemisphere.
  15613. */
  15614. radius?: number,
  15615. /**
  15616. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15617. */
  15618. radiusRange?: number,
  15619. /**
  15620. * How much to randomize the particle direction [0-1].
  15621. */
  15622. directionRandomizer?: number);
  15623. /**
  15624. * Called by the particle System when the direction is computed for the created particle.
  15625. * @param worldMatrix is the world matrix of the particle system
  15626. * @param directionToUpdate is the direction vector to update with the result
  15627. * @param particle is the particle we are computed the direction for
  15628. */
  15629. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15630. /**
  15631. * Called by the particle System when the position is computed for the created particle.
  15632. * @param worldMatrix is the world matrix of the particle system
  15633. * @param positionToUpdate is the position vector to update with the result
  15634. * @param particle is the particle we are computed the position for
  15635. */
  15636. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15637. /**
  15638. * Clones the current emitter and returns a copy of it
  15639. * @returns the new emitter
  15640. */
  15641. clone(): HemisphericParticleEmitter;
  15642. /**
  15643. * Called by the GPUParticleSystem to setup the update shader
  15644. * @param effect defines the update shader
  15645. */
  15646. applyToShader(effect: Effect): void;
  15647. /**
  15648. * Returns a string to use to update the GPU particles update shader
  15649. * @returns a string containng the defines string
  15650. */
  15651. getEffectDefines(): string;
  15652. /**
  15653. * Returns the string "HemisphericParticleEmitter"
  15654. * @returns a string containing the class name
  15655. */
  15656. getClassName(): string;
  15657. /**
  15658. * Serializes the particle system to a JSON object.
  15659. * @returns the JSON object
  15660. */
  15661. serialize(): any;
  15662. /**
  15663. * Parse properties from a JSON object
  15664. * @param serializationObject defines the JSON object
  15665. */
  15666. parse(serializationObject: any): void;
  15667. }
  15668. }
  15669. declare module BABYLON {
  15670. /**
  15671. * Particle emitter emitting particles from a point.
  15672. * It emits the particles randomly between 2 given directions.
  15673. */
  15674. export class PointParticleEmitter implements IParticleEmitterType {
  15675. /**
  15676. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15677. */
  15678. direction1: Vector3;
  15679. /**
  15680. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15681. */
  15682. direction2: Vector3;
  15683. /**
  15684. * Creates a new instance PointParticleEmitter
  15685. */
  15686. constructor();
  15687. /**
  15688. * Called by the particle System when the direction is computed for the created particle.
  15689. * @param worldMatrix is the world matrix of the particle system
  15690. * @param directionToUpdate is the direction vector to update with the result
  15691. * @param particle is the particle we are computed the direction for
  15692. */
  15693. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15694. /**
  15695. * Called by the particle System when the position is computed for the created particle.
  15696. * @param worldMatrix is the world matrix of the particle system
  15697. * @param positionToUpdate is the position vector to update with the result
  15698. * @param particle is the particle we are computed the position for
  15699. */
  15700. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15701. /**
  15702. * Clones the current emitter and returns a copy of it
  15703. * @returns the new emitter
  15704. */
  15705. clone(): PointParticleEmitter;
  15706. /**
  15707. * Called by the GPUParticleSystem to setup the update shader
  15708. * @param effect defines the update shader
  15709. */
  15710. applyToShader(effect: Effect): void;
  15711. /**
  15712. * Returns a string to use to update the GPU particles update shader
  15713. * @returns a string containng the defines string
  15714. */
  15715. getEffectDefines(): string;
  15716. /**
  15717. * Returns the string "PointParticleEmitter"
  15718. * @returns a string containing the class name
  15719. */
  15720. getClassName(): string;
  15721. /**
  15722. * Serializes the particle system to a JSON object.
  15723. * @returns the JSON object
  15724. */
  15725. serialize(): any;
  15726. /**
  15727. * Parse properties from a JSON object
  15728. * @param serializationObject defines the JSON object
  15729. */
  15730. parse(serializationObject: any): void;
  15731. }
  15732. }
  15733. declare module BABYLON {
  15734. /**
  15735. * Particle emitter emitting particles from the inside of a sphere.
  15736. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15737. */
  15738. export class SphereParticleEmitter implements IParticleEmitterType {
  15739. /**
  15740. * The radius of the emission sphere.
  15741. */
  15742. radius: number;
  15743. /**
  15744. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15745. */
  15746. radiusRange: number;
  15747. /**
  15748. * How much to randomize the particle direction [0-1].
  15749. */
  15750. directionRandomizer: number;
  15751. /**
  15752. * Creates a new instance SphereParticleEmitter
  15753. * @param radius the radius of the emission sphere (1 by default)
  15754. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15755. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15756. */
  15757. constructor(
  15758. /**
  15759. * The radius of the emission sphere.
  15760. */
  15761. radius?: number,
  15762. /**
  15763. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15764. */
  15765. radiusRange?: number,
  15766. /**
  15767. * How much to randomize the particle direction [0-1].
  15768. */
  15769. directionRandomizer?: number);
  15770. /**
  15771. * Called by the particle System when the direction is computed for the created particle.
  15772. * @param worldMatrix is the world matrix of the particle system
  15773. * @param directionToUpdate is the direction vector to update with the result
  15774. * @param particle is the particle we are computed the direction for
  15775. */
  15776. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15777. /**
  15778. * Called by the particle System when the position is computed for the created particle.
  15779. * @param worldMatrix is the world matrix of the particle system
  15780. * @param positionToUpdate is the position vector to update with the result
  15781. * @param particle is the particle we are computed the position for
  15782. */
  15783. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15784. /**
  15785. * Clones the current emitter and returns a copy of it
  15786. * @returns the new emitter
  15787. */
  15788. clone(): SphereParticleEmitter;
  15789. /**
  15790. * Called by the GPUParticleSystem to setup the update shader
  15791. * @param effect defines the update shader
  15792. */
  15793. applyToShader(effect: Effect): void;
  15794. /**
  15795. * Returns a string to use to update the GPU particles update shader
  15796. * @returns a string containng the defines string
  15797. */
  15798. getEffectDefines(): string;
  15799. /**
  15800. * Returns the string "SphereParticleEmitter"
  15801. * @returns a string containing the class name
  15802. */
  15803. getClassName(): string;
  15804. /**
  15805. * Serializes the particle system to a JSON object.
  15806. * @returns the JSON object
  15807. */
  15808. serialize(): any;
  15809. /**
  15810. * Parse properties from a JSON object
  15811. * @param serializationObject defines the JSON object
  15812. */
  15813. parse(serializationObject: any): void;
  15814. }
  15815. /**
  15816. * Particle emitter emitting particles from the inside of a sphere.
  15817. * It emits the particles randomly between two vectors.
  15818. */
  15819. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15820. /**
  15821. * The min limit of the emission direction.
  15822. */
  15823. direction1: Vector3;
  15824. /**
  15825. * The max limit of the emission direction.
  15826. */
  15827. direction2: Vector3;
  15828. /**
  15829. * Creates a new instance SphereDirectedParticleEmitter
  15830. * @param radius the radius of the emission sphere (1 by default)
  15831. * @param direction1 the min limit of the emission direction (up vector by default)
  15832. * @param direction2 the max limit of the emission direction (up vector by default)
  15833. */
  15834. constructor(radius?: number,
  15835. /**
  15836. * The min limit of the emission direction.
  15837. */
  15838. direction1?: Vector3,
  15839. /**
  15840. * The max limit of the emission direction.
  15841. */
  15842. direction2?: Vector3);
  15843. /**
  15844. * Called by the particle System when the direction is computed for the created particle.
  15845. * @param worldMatrix is the world matrix of the particle system
  15846. * @param directionToUpdate is the direction vector to update with the result
  15847. * @param particle is the particle we are computed the direction for
  15848. */
  15849. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15850. /**
  15851. * Clones the current emitter and returns a copy of it
  15852. * @returns the new emitter
  15853. */
  15854. clone(): SphereDirectedParticleEmitter;
  15855. /**
  15856. * Called by the GPUParticleSystem to setup the update shader
  15857. * @param effect defines the update shader
  15858. */
  15859. applyToShader(effect: Effect): void;
  15860. /**
  15861. * Returns a string to use to update the GPU particles update shader
  15862. * @returns a string containng the defines string
  15863. */
  15864. getEffectDefines(): string;
  15865. /**
  15866. * Returns the string "SphereDirectedParticleEmitter"
  15867. * @returns a string containing the class name
  15868. */
  15869. getClassName(): string;
  15870. /**
  15871. * Serializes the particle system to a JSON object.
  15872. * @returns the JSON object
  15873. */
  15874. serialize(): any;
  15875. /**
  15876. * Parse properties from a JSON object
  15877. * @param serializationObject defines the JSON object
  15878. */
  15879. parse(serializationObject: any): void;
  15880. }
  15881. }
  15882. declare module BABYLON {
  15883. /**
  15884. * Interface representing a particle system in Babylon.js.
  15885. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15886. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15887. */
  15888. export interface IParticleSystem {
  15889. /**
  15890. * List of animations used by the particle system.
  15891. */
  15892. animations: Animation[];
  15893. /**
  15894. * The id of the Particle system.
  15895. */
  15896. id: string;
  15897. /**
  15898. * The name of the Particle system.
  15899. */
  15900. name: string;
  15901. /**
  15902. * The emitter represents the Mesh or position we are attaching the particle system to.
  15903. */
  15904. emitter: Nullable<AbstractMesh | Vector3>;
  15905. /**
  15906. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15907. */
  15908. isBillboardBased: boolean;
  15909. /**
  15910. * The rendering group used by the Particle system to chose when to render.
  15911. */
  15912. renderingGroupId: number;
  15913. /**
  15914. * The layer mask we are rendering the particles through.
  15915. */
  15916. layerMask: number;
  15917. /**
  15918. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15919. */
  15920. updateSpeed: number;
  15921. /**
  15922. * The amount of time the particle system is running (depends of the overall update speed).
  15923. */
  15924. targetStopDuration: number;
  15925. /**
  15926. * The texture used to render each particle. (this can be a spritesheet)
  15927. */
  15928. particleTexture: Nullable<Texture>;
  15929. /**
  15930. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15931. */
  15932. blendMode: number;
  15933. /**
  15934. * Minimum life time of emitting particles.
  15935. */
  15936. minLifeTime: number;
  15937. /**
  15938. * Maximum life time of emitting particles.
  15939. */
  15940. maxLifeTime: number;
  15941. /**
  15942. * Minimum Size of emitting particles.
  15943. */
  15944. minSize: number;
  15945. /**
  15946. * Maximum Size of emitting particles.
  15947. */
  15948. maxSize: number;
  15949. /**
  15950. * Minimum scale of emitting particles on X axis.
  15951. */
  15952. minScaleX: number;
  15953. /**
  15954. * Maximum scale of emitting particles on X axis.
  15955. */
  15956. maxScaleX: number;
  15957. /**
  15958. * Minimum scale of emitting particles on Y axis.
  15959. */
  15960. minScaleY: number;
  15961. /**
  15962. * Maximum scale of emitting particles on Y axis.
  15963. */
  15964. maxScaleY: number;
  15965. /**
  15966. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15967. */
  15968. color1: Color4;
  15969. /**
  15970. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15971. */
  15972. color2: Color4;
  15973. /**
  15974. * Color the particle will have at the end of its lifetime.
  15975. */
  15976. colorDead: Color4;
  15977. /**
  15978. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15979. */
  15980. emitRate: number;
  15981. /**
  15982. * You can use gravity if you want to give an orientation to your particles.
  15983. */
  15984. gravity: Vector3;
  15985. /**
  15986. * Minimum power of emitting particles.
  15987. */
  15988. minEmitPower: number;
  15989. /**
  15990. * Maximum power of emitting particles.
  15991. */
  15992. maxEmitPower: number;
  15993. /**
  15994. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15995. */
  15996. minAngularSpeed: number;
  15997. /**
  15998. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15999. */
  16000. maxAngularSpeed: number;
  16001. /**
  16002. * Gets or sets the minimal initial rotation in radians.
  16003. */
  16004. minInitialRotation: number;
  16005. /**
  16006. * Gets or sets the maximal initial rotation in radians.
  16007. */
  16008. maxInitialRotation: number;
  16009. /**
  16010. * The particle emitter type defines the emitter used by the particle system.
  16011. * It can be for example box, sphere, or cone...
  16012. */
  16013. particleEmitterType: Nullable<IParticleEmitterType>;
  16014. /**
  16015. * Defines the delay in milliseconds before starting the system (0 by default)
  16016. */
  16017. startDelay: number;
  16018. /**
  16019. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  16020. */
  16021. preWarmCycles: number;
  16022. /**
  16023. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16024. */
  16025. preWarmStepOffset: number;
  16026. /**
  16027. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16028. */
  16029. spriteCellChangeSpeed: number;
  16030. /**
  16031. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16032. */
  16033. startSpriteCellID: number;
  16034. /**
  16035. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16036. */
  16037. endSpriteCellID: number;
  16038. /**
  16039. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16040. */
  16041. spriteCellWidth: number;
  16042. /**
  16043. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16044. */
  16045. spriteCellHeight: number;
  16046. /**
  16047. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16048. */
  16049. spriteRandomStartCell: boolean;
  16050. /**
  16051. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16052. */
  16053. isAnimationSheetEnabled: boolean;
  16054. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16055. translationPivot: Vector2;
  16056. /**
  16057. * Gets or sets a texture used to add random noise to particle positions
  16058. */
  16059. noiseTexture: Nullable<BaseTexture>;
  16060. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16061. noiseStrength: Vector3;
  16062. /**
  16063. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16064. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16065. */
  16066. billboardMode: number;
  16067. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16068. limitVelocityDamping: number;
  16069. /**
  16070. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16071. */
  16072. beginAnimationOnStart: boolean;
  16073. /**
  16074. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16075. */
  16076. beginAnimationFrom: number;
  16077. /**
  16078. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16079. */
  16080. beginAnimationTo: number;
  16081. /**
  16082. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16083. */
  16084. beginAnimationLoop: boolean;
  16085. /**
  16086. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16087. */
  16088. disposeOnStop: boolean;
  16089. /**
  16090. * Gets the maximum number of particles active at the same time.
  16091. * @returns The max number of active particles.
  16092. */
  16093. getCapacity(): number;
  16094. /**
  16095. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16096. * @returns True if it has been started, otherwise false.
  16097. */
  16098. isStarted(): boolean;
  16099. /**
  16100. * Animates the particle system for this frame.
  16101. */
  16102. animate(): void;
  16103. /**
  16104. * Renders the particle system in its current state.
  16105. * @returns the current number of particles
  16106. */
  16107. render(): number;
  16108. /**
  16109. * Dispose the particle system and frees its associated resources.
  16110. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16111. */
  16112. dispose(disposeTexture?: boolean): void;
  16113. /**
  16114. * Clones the particle system.
  16115. * @param name The name of the cloned object
  16116. * @param newEmitter The new emitter to use
  16117. * @returns the cloned particle system
  16118. */
  16119. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16120. /**
  16121. * Serializes the particle system to a JSON object.
  16122. * @returns the JSON object
  16123. */
  16124. serialize(): any;
  16125. /**
  16126. * Rebuild the particle system
  16127. */
  16128. rebuild(): void;
  16129. /**
  16130. * Starts the particle system and begins to emit
  16131. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16132. */
  16133. start(delay?: number): void;
  16134. /**
  16135. * Stops the particle system.
  16136. */
  16137. stop(): void;
  16138. /**
  16139. * Remove all active particles
  16140. */
  16141. reset(): void;
  16142. /**
  16143. * Is this system ready to be used/rendered
  16144. * @return true if the system is ready
  16145. */
  16146. isReady(): boolean;
  16147. /**
  16148. * Adds a new color gradient
  16149. * @param gradient defines the gradient to use (between 0 and 1)
  16150. * @param color1 defines the color to affect to the specified gradient
  16151. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16152. * @returns the current particle system
  16153. */
  16154. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16155. /**
  16156. * Remove a specific color gradient
  16157. * @param gradient defines the gradient to remove
  16158. * @returns the current particle system
  16159. */
  16160. removeColorGradient(gradient: number): IParticleSystem;
  16161. /**
  16162. * Adds a new size gradient
  16163. * @param gradient defines the gradient to use (between 0 and 1)
  16164. * @param factor defines the size factor to affect to the specified gradient
  16165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16166. * @returns the current particle system
  16167. */
  16168. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16169. /**
  16170. * Remove a specific size gradient
  16171. * @param gradient defines the gradient to remove
  16172. * @returns the current particle system
  16173. */
  16174. removeSizeGradient(gradient: number): IParticleSystem;
  16175. /**
  16176. * Gets the current list of color gradients.
  16177. * You must use addColorGradient and removeColorGradient to udpate this list
  16178. * @returns the list of color gradients
  16179. */
  16180. getColorGradients(): Nullable<Array<ColorGradient>>;
  16181. /**
  16182. * Gets the current list of size gradients.
  16183. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16184. * @returns the list of size gradients
  16185. */
  16186. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16187. /**
  16188. * Gets the current list of angular speed gradients.
  16189. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16190. * @returns the list of angular speed gradients
  16191. */
  16192. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16193. /**
  16194. * Adds a new angular speed gradient
  16195. * @param gradient defines the gradient to use (between 0 and 1)
  16196. * @param factor defines the angular speed to affect to the specified gradient
  16197. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16198. * @returns the current particle system
  16199. */
  16200. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16201. /**
  16202. * Remove a specific angular speed gradient
  16203. * @param gradient defines the gradient to remove
  16204. * @returns the current particle system
  16205. */
  16206. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16207. /**
  16208. * Gets the current list of velocity gradients.
  16209. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16210. * @returns the list of velocity gradients
  16211. */
  16212. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16213. /**
  16214. * Adds a new velocity gradient
  16215. * @param gradient defines the gradient to use (between 0 and 1)
  16216. * @param factor defines the velocity to affect to the specified gradient
  16217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16218. * @returns the current particle system
  16219. */
  16220. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16221. /**
  16222. * Remove a specific velocity gradient
  16223. * @param gradient defines the gradient to remove
  16224. * @returns the current particle system
  16225. */
  16226. removeVelocityGradient(gradient: number): IParticleSystem;
  16227. /**
  16228. * Gets the current list of limit velocity gradients.
  16229. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16230. * @returns the list of limit velocity gradients
  16231. */
  16232. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16233. /**
  16234. * Adds a new limit velocity gradient
  16235. * @param gradient defines the gradient to use (between 0 and 1)
  16236. * @param factor defines the limit velocity to affect to the specified gradient
  16237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16238. * @returns the current particle system
  16239. */
  16240. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16241. /**
  16242. * Remove a specific limit velocity gradient
  16243. * @param gradient defines the gradient to remove
  16244. * @returns the current particle system
  16245. */
  16246. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16247. /**
  16248. * Adds a new drag gradient
  16249. * @param gradient defines the gradient to use (between 0 and 1)
  16250. * @param factor defines the drag to affect to the specified gradient
  16251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16252. * @returns the current particle system
  16253. */
  16254. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16255. /**
  16256. * Remove a specific drag gradient
  16257. * @param gradient defines the gradient to remove
  16258. * @returns the current particle system
  16259. */
  16260. removeDragGradient(gradient: number): IParticleSystem;
  16261. /**
  16262. * Gets the current list of drag gradients.
  16263. * You must use addDragGradient and removeDragGradient to udpate this list
  16264. * @returns the list of drag gradients
  16265. */
  16266. getDragGradients(): Nullable<Array<FactorGradient>>;
  16267. /**
  16268. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16269. * @param gradient defines the gradient to use (between 0 and 1)
  16270. * @param factor defines the emit rate to affect to the specified gradient
  16271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16272. * @returns the current particle system
  16273. */
  16274. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16275. /**
  16276. * Remove a specific emit rate gradient
  16277. * @param gradient defines the gradient to remove
  16278. * @returns the current particle system
  16279. */
  16280. removeEmitRateGradient(gradient: number): IParticleSystem;
  16281. /**
  16282. * Gets the current list of emit rate gradients.
  16283. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16284. * @returns the list of emit rate gradients
  16285. */
  16286. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16287. /**
  16288. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16289. * @param gradient defines the gradient to use (between 0 and 1)
  16290. * @param factor defines the start size to affect to the specified gradient
  16291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16292. * @returns the current particle system
  16293. */
  16294. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16295. /**
  16296. * Remove a specific start size gradient
  16297. * @param gradient defines the gradient to remove
  16298. * @returns the current particle system
  16299. */
  16300. removeStartSizeGradient(gradient: number): IParticleSystem;
  16301. /**
  16302. * Gets the current list of start size gradients.
  16303. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16304. * @returns the list of start size gradients
  16305. */
  16306. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16307. /**
  16308. * Adds a new life time gradient
  16309. * @param gradient defines the gradient to use (between 0 and 1)
  16310. * @param factor defines the life time factor to affect to the specified gradient
  16311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16312. * @returns the current particle system
  16313. */
  16314. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16315. /**
  16316. * Remove a specific life time gradient
  16317. * @param gradient defines the gradient to remove
  16318. * @returns the current particle system
  16319. */
  16320. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16321. /**
  16322. * Gets the current list of life time gradients.
  16323. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16324. * @returns the list of life time gradients
  16325. */
  16326. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16327. /**
  16328. * Gets the current list of color gradients.
  16329. * You must use addColorGradient and removeColorGradient to udpate this list
  16330. * @returns the list of color gradients
  16331. */
  16332. getColorGradients(): Nullable<Array<ColorGradient>>;
  16333. /**
  16334. * Adds a new ramp gradient used to remap particle colors
  16335. * @param gradient defines the gradient to use (between 0 and 1)
  16336. * @param color defines the color to affect to the specified gradient
  16337. * @returns the current particle system
  16338. */
  16339. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16340. /**
  16341. * Gets the current list of ramp gradients.
  16342. * You must use addRampGradient and removeRampGradient to udpate this list
  16343. * @returns the list of ramp gradients
  16344. */
  16345. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16346. /** Gets or sets a boolean indicating that ramp gradients must be used
  16347. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16348. */
  16349. useRampGradients: boolean;
  16350. /**
  16351. * Adds a new color remap gradient
  16352. * @param gradient defines the gradient to use (between 0 and 1)
  16353. * @param min defines the color remap minimal range
  16354. * @param max defines the color remap maximal range
  16355. * @returns the current particle system
  16356. */
  16357. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16358. /**
  16359. * Gets the current list of color remap gradients.
  16360. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16361. * @returns the list of color remap gradients
  16362. */
  16363. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16364. /**
  16365. * Adds a new alpha remap gradient
  16366. * @param gradient defines the gradient to use (between 0 and 1)
  16367. * @param min defines the alpha remap minimal range
  16368. * @param max defines the alpha remap maximal range
  16369. * @returns the current particle system
  16370. */
  16371. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16372. /**
  16373. * Gets the current list of alpha remap gradients.
  16374. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16375. * @returns the list of alpha remap gradients
  16376. */
  16377. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16378. /**
  16379. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16380. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16381. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16382. * @returns the emitter
  16383. */
  16384. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16385. /**
  16386. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16387. * @param radius The radius of the hemisphere to emit from
  16388. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16389. * @returns the emitter
  16390. */
  16391. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16392. /**
  16393. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16394. * @param radius The radius of the sphere to emit from
  16395. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16396. * @returns the emitter
  16397. */
  16398. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16399. /**
  16400. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16401. * @param radius The radius of the sphere to emit from
  16402. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16403. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16404. * @returns the emitter
  16405. */
  16406. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16407. /**
  16408. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16409. * @param radius The radius of the emission cylinder
  16410. * @param height The height of the emission cylinder
  16411. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16412. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16413. * @returns the emitter
  16414. */
  16415. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16416. /**
  16417. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16418. * @param radius The radius of the cylinder to emit from
  16419. * @param height The height of the emission cylinder
  16420. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16421. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16422. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16423. * @returns the emitter
  16424. */
  16425. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16426. /**
  16427. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16428. * @param radius The radius of the cone to emit from
  16429. * @param angle The base angle of the cone
  16430. * @returns the emitter
  16431. */
  16432. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16433. /**
  16434. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16435. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16436. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16437. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16438. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16439. * @returns the emitter
  16440. */
  16441. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16442. /**
  16443. * Get hosting scene
  16444. * @returns the scene
  16445. */
  16446. getScene(): Scene;
  16447. }
  16448. }
  16449. declare module BABYLON {
  16450. /**
  16451. * Creates an instance based on a source mesh.
  16452. */
  16453. export class InstancedMesh extends AbstractMesh {
  16454. private _sourceMesh;
  16455. private _currentLOD;
  16456. /** @hidden */ indexInSourceMeshInstanceArray: number;
  16457. constructor(name: string, source: Mesh);
  16458. /**
  16459. * Returns the string "InstancedMesh".
  16460. */
  16461. getClassName(): string;
  16462. /** Gets the list of lights affecting that mesh */
  16463. readonly lightSources: Light[]; resyncLightSources(): void; resyncLighSource(light: Light): void; removeLightSource(light: Light): void;
  16464. /**
  16465. * If the source mesh receives shadows
  16466. */
  16467. readonly receiveShadows: boolean;
  16468. /**
  16469. * The material of the source mesh
  16470. */
  16471. readonly material: Nullable<Material>;
  16472. /**
  16473. * Visibility of the source mesh
  16474. */
  16475. readonly visibility: number;
  16476. /**
  16477. * Skeleton of the source mesh
  16478. */
  16479. readonly skeleton: Nullable<Skeleton>;
  16480. /**
  16481. * Rendering ground id of the source mesh
  16482. */
  16483. renderingGroupId: number;
  16484. /**
  16485. * Returns the total number of vertices (integer).
  16486. */
  16487. getTotalVertices(): number;
  16488. /**
  16489. * Returns a positive integer : the total number of indices in this mesh geometry.
  16490. * @returns the numner of indices or zero if the mesh has no geometry.
  16491. */
  16492. getTotalIndices(): number;
  16493. /**
  16494. * The source mesh of the instance
  16495. */
  16496. readonly sourceMesh: Mesh;
  16497. /**
  16498. * Is this node ready to be used/rendered
  16499. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16500. * @return {boolean} is it ready
  16501. */
  16502. isReady(completeCheck?: boolean): boolean;
  16503. /**
  16504. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16505. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16506. * @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.
  16507. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16508. */
  16509. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16510. /**
  16511. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16512. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16513. * The `data` are either a numeric array either a Float32Array.
  16514. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16515. * 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).
  16516. * Note that a new underlying VertexBuffer object is created each call.
  16517. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16518. *
  16519. * Possible `kind` values :
  16520. * - VertexBuffer.PositionKind
  16521. * - VertexBuffer.UVKind
  16522. * - VertexBuffer.UV2Kind
  16523. * - VertexBuffer.UV3Kind
  16524. * - VertexBuffer.UV4Kind
  16525. * - VertexBuffer.UV5Kind
  16526. * - VertexBuffer.UV6Kind
  16527. * - VertexBuffer.ColorKind
  16528. * - VertexBuffer.MatricesIndicesKind
  16529. * - VertexBuffer.MatricesIndicesExtraKind
  16530. * - VertexBuffer.MatricesWeightsKind
  16531. * - VertexBuffer.MatricesWeightsExtraKind
  16532. *
  16533. * Returns the Mesh.
  16534. */
  16535. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16536. /**
  16537. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16538. * If the mesh has no geometry, it is simply returned as it is.
  16539. * The `data` are either a numeric array either a Float32Array.
  16540. * No new underlying VertexBuffer object is created.
  16541. * 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.
  16542. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16543. *
  16544. * Possible `kind` values :
  16545. * - VertexBuffer.PositionKind
  16546. * - VertexBuffer.UVKind
  16547. * - VertexBuffer.UV2Kind
  16548. * - VertexBuffer.UV3Kind
  16549. * - VertexBuffer.UV4Kind
  16550. * - VertexBuffer.UV5Kind
  16551. * - VertexBuffer.UV6Kind
  16552. * - VertexBuffer.ColorKind
  16553. * - VertexBuffer.MatricesIndicesKind
  16554. * - VertexBuffer.MatricesIndicesExtraKind
  16555. * - VertexBuffer.MatricesWeightsKind
  16556. * - VertexBuffer.MatricesWeightsExtraKind
  16557. *
  16558. * Returns the Mesh.
  16559. */
  16560. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16561. /**
  16562. * Sets the mesh indices.
  16563. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16564. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16565. * This method creates a new index buffer each call.
  16566. * Returns the Mesh.
  16567. */
  16568. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16569. /**
  16570. * Boolean : True if the mesh owns the requested kind of data.
  16571. */
  16572. isVerticesDataPresent(kind: string): boolean;
  16573. /**
  16574. * Returns an array of indices (IndicesArray).
  16575. */
  16576. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  16577. /**
  16578. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16579. * This means the mesh underlying bounding box and sphere are recomputed.
  16580. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16581. * @returns the current mesh
  16582. */
  16583. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16584. /** @hidden */ preActivate(): InstancedMesh;
  16585. /** @hidden */ activate(renderId: number): boolean;
  16586. getWorldMatrix(): Matrix;
  16587. /**
  16588. * Returns the current associated LOD AbstractMesh.
  16589. */
  16590. getLOD(camera: Camera): AbstractMesh;
  16591. /** @hidden */ syncSubMeshes(): InstancedMesh;
  16592. /** @hidden */ generatePointsArray(): boolean;
  16593. /**
  16594. * Creates a new InstancedMesh from the current mesh.
  16595. * - name (string) : the cloned mesh name
  16596. * - newParent (optional Node) : the optional Node to parent the clone to.
  16597. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16598. *
  16599. * Returns the clone.
  16600. */
  16601. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16602. /**
  16603. * Disposes the InstancedMesh.
  16604. * Returns nothing.
  16605. */
  16606. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16607. }
  16608. }
  16609. declare module BABYLON {
  16610. /**
  16611. * Defines the options associated with the creation of a shader material.
  16612. */
  16613. export interface IShaderMaterialOptions {
  16614. /**
  16615. * Does the material work in alpha blend mode
  16616. */
  16617. needAlphaBlending: boolean;
  16618. /**
  16619. * Does the material work in alpha test mode
  16620. */
  16621. needAlphaTesting: boolean;
  16622. /**
  16623. * The list of attribute names used in the shader
  16624. */
  16625. attributes: string[];
  16626. /**
  16627. * The list of unifrom names used in the shader
  16628. */
  16629. uniforms: string[];
  16630. /**
  16631. * The list of UBO names used in the shader
  16632. */
  16633. uniformBuffers: string[];
  16634. /**
  16635. * The list of sampler names used in the shader
  16636. */
  16637. samplers: string[];
  16638. /**
  16639. * The list of defines used in the shader
  16640. */
  16641. defines: string[];
  16642. }
  16643. /**
  16644. * 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.
  16645. *
  16646. * This returned material effects how the mesh will look based on the code in the shaders.
  16647. *
  16648. * @see http://doc.babylonjs.com/how_to/shader_material
  16649. */
  16650. export class ShaderMaterial extends Material {
  16651. private _shaderPath;
  16652. private _options;
  16653. private _textures;
  16654. private _textureArrays;
  16655. private _floats;
  16656. private _ints;
  16657. private _floatsArrays;
  16658. private _colors3;
  16659. private _colors3Arrays;
  16660. private _colors4;
  16661. private _vectors2;
  16662. private _vectors3;
  16663. private _vectors4;
  16664. private _matrices;
  16665. private _matrices3x3;
  16666. private _matrices2x2;
  16667. private _vectors2Arrays;
  16668. private _vectors3Arrays;
  16669. private _cachedWorldViewMatrix;
  16670. private _renderId;
  16671. /**
  16672. * Instantiate a new shader material.
  16673. * 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.
  16674. * This returned material effects how the mesh will look based on the code in the shaders.
  16675. * @see http://doc.babylonjs.com/how_to/shader_material
  16676. * @param name Define the name of the material in the scene
  16677. * @param scene Define the scene the material belongs to
  16678. * @param shaderPath Defines the route to the shader code in one of three ways:
  16679. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16680. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16681. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16682. * @param options Define the options used to create the shader
  16683. */
  16684. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16685. /**
  16686. * Gets the options used to compile the shader.
  16687. * They can be modified to trigger a new compilation
  16688. */
  16689. readonly options: IShaderMaterialOptions;
  16690. /**
  16691. * Gets the current class name of the material e.g. "ShaderMaterial"
  16692. * Mainly use in serialization.
  16693. * @returns the class name
  16694. */
  16695. getClassName(): string;
  16696. /**
  16697. * Specifies if the material will require alpha blending
  16698. * @returns a boolean specifying if alpha blending is needed
  16699. */
  16700. needAlphaBlending(): boolean;
  16701. /**
  16702. * Specifies if this material should be rendered in alpha test mode
  16703. * @returns a boolean specifying if an alpha test is needed.
  16704. */
  16705. needAlphaTesting(): boolean;
  16706. private _checkUniform;
  16707. /**
  16708. * Set a texture in the shader.
  16709. * @param name Define the name of the uniform samplers as defined in the shader
  16710. * @param texture Define the texture to bind to this sampler
  16711. * @return the material itself allowing "fluent" like uniform updates
  16712. */
  16713. setTexture(name: string, texture: Texture): ShaderMaterial;
  16714. /**
  16715. * Set a texture array in the shader.
  16716. * @param name Define the name of the uniform sampler array as defined in the shader
  16717. * @param textures Define the list of textures to bind to this sampler
  16718. * @return the material itself allowing "fluent" like uniform updates
  16719. */
  16720. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16721. /**
  16722. * Set a float in the shader.
  16723. * @param name Define the name of the uniform as defined in the shader
  16724. * @param value Define the value to give to the uniform
  16725. * @return the material itself allowing "fluent" like uniform updates
  16726. */
  16727. setFloat(name: string, value: number): ShaderMaterial;
  16728. /**
  16729. * Set a int in the shader.
  16730. * @param name Define the name of the uniform as defined in the shader
  16731. * @param value Define the value to give to the uniform
  16732. * @return the material itself allowing "fluent" like uniform updates
  16733. */
  16734. setInt(name: string, value: number): ShaderMaterial;
  16735. /**
  16736. * Set an array of floats in the shader.
  16737. * @param name Define the name of the uniform as defined in the shader
  16738. * @param value Define the value to give to the uniform
  16739. * @return the material itself allowing "fluent" like uniform updates
  16740. */
  16741. setFloats(name: string, value: number[]): ShaderMaterial;
  16742. /**
  16743. * Set a vec3 in the shader from a Color3.
  16744. * @param name Define the name of the uniform as defined in the shader
  16745. * @param value Define the value to give to the uniform
  16746. * @return the material itself allowing "fluent" like uniform updates
  16747. */
  16748. setColor3(name: string, value: Color3): ShaderMaterial;
  16749. /**
  16750. * Set a vec3 array in the shader from a Color3 array.
  16751. * @param name Define the name of the uniform as defined in the shader
  16752. * @param value Define the value to give to the uniform
  16753. * @return the material itself allowing "fluent" like uniform updates
  16754. */
  16755. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16756. /**
  16757. * Set a vec4 in the shader from a Color4.
  16758. * @param name Define the name of the uniform as defined in the shader
  16759. * @param value Define the value to give to the uniform
  16760. * @return the material itself allowing "fluent" like uniform updates
  16761. */
  16762. setColor4(name: string, value: Color4): ShaderMaterial;
  16763. /**
  16764. * Set a vec2 in the shader from a Vector2.
  16765. * @param name Define the name of the uniform as defined in the shader
  16766. * @param value Define the value to give to the uniform
  16767. * @return the material itself allowing "fluent" like uniform updates
  16768. */
  16769. setVector2(name: string, value: Vector2): ShaderMaterial;
  16770. /**
  16771. * Set a vec3 in the shader from a Vector3.
  16772. * @param name Define the name of the uniform as defined in the shader
  16773. * @param value Define the value to give to the uniform
  16774. * @return the material itself allowing "fluent" like uniform updates
  16775. */
  16776. setVector3(name: string, value: Vector3): ShaderMaterial;
  16777. /**
  16778. * Set a vec4 in the shader from a Vector4.
  16779. * @param name Define the name of the uniform as defined in the shader
  16780. * @param value Define the value to give to the uniform
  16781. * @return the material itself allowing "fluent" like uniform updates
  16782. */
  16783. setVector4(name: string, value: Vector4): ShaderMaterial;
  16784. /**
  16785. * Set a mat4 in the shader from a Matrix.
  16786. * @param name Define the name of the uniform as defined in the shader
  16787. * @param value Define the value to give to the uniform
  16788. * @return the material itself allowing "fluent" like uniform updates
  16789. */
  16790. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16791. /**
  16792. * Set a mat3 in the shader from a Float32Array.
  16793. * @param name Define the name of the uniform as defined in the shader
  16794. * @param value Define the value to give to the uniform
  16795. * @return the material itself allowing "fluent" like uniform updates
  16796. */
  16797. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16798. /**
  16799. * Set a mat2 in the shader from a Float32Array.
  16800. * @param name Define the name of the uniform as defined in the shader
  16801. * @param value Define the value to give to the uniform
  16802. * @return the material itself allowing "fluent" like uniform updates
  16803. */
  16804. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16805. /**
  16806. * Set a vec2 array in the shader from a number array.
  16807. * @param name Define the name of the uniform as defined in the shader
  16808. * @param value Define the value to give to the uniform
  16809. * @return the material itself allowing "fluent" like uniform updates
  16810. */
  16811. setArray2(name: string, value: number[]): ShaderMaterial;
  16812. /**
  16813. * Set a vec3 array in the shader from a number array.
  16814. * @param name Define the name of the uniform as defined in the shader
  16815. * @param value Define the value to give to the uniform
  16816. * @return the material itself allowing "fluent" like uniform updates
  16817. */
  16818. setArray3(name: string, value: number[]): ShaderMaterial;
  16819. private _checkCache;
  16820. /**
  16821. * Specifies that the submesh is ready to be used
  16822. * @param mesh defines the mesh to check
  16823. * @param subMesh defines which submesh to check
  16824. * @param useInstances specifies that instances should be used
  16825. * @returns a boolean indicating that the submesh is ready or not
  16826. */
  16827. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16828. /**
  16829. * Checks if the material is ready to render the requested mesh
  16830. * @param mesh Define the mesh to render
  16831. * @param useInstances Define whether or not the material is used with instances
  16832. * @returns true if ready, otherwise false
  16833. */
  16834. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16835. /**
  16836. * Binds the world matrix to the material
  16837. * @param world defines the world transformation matrix
  16838. */
  16839. bindOnlyWorldMatrix(world: Matrix): void;
  16840. /**
  16841. * Binds the material to the mesh
  16842. * @param world defines the world transformation matrix
  16843. * @param mesh defines the mesh to bind the material to
  16844. */
  16845. bind(world: Matrix, mesh?: Mesh): void;
  16846. /**
  16847. * Gets the active textures from the material
  16848. * @returns an array of textures
  16849. */
  16850. getActiveTextures(): BaseTexture[];
  16851. /**
  16852. * Specifies if the material uses a texture
  16853. * @param texture defines the texture to check against the material
  16854. * @returns a boolean specifying if the material uses the texture
  16855. */
  16856. hasTexture(texture: BaseTexture): boolean;
  16857. /**
  16858. * Makes a duplicate of the material, and gives it a new name
  16859. * @param name defines the new name for the duplicated material
  16860. * @returns the cloned material
  16861. */
  16862. clone(name: string): ShaderMaterial;
  16863. /**
  16864. * Disposes the material
  16865. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16866. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16867. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16868. */
  16869. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16870. /**
  16871. * Serializes this material in a JSON representation
  16872. * @returns the serialized material object
  16873. */
  16874. serialize(): any;
  16875. /**
  16876. * Creates a shader material from parsed shader material data
  16877. * @param source defines the JSON represnetation of the material
  16878. * @param scene defines the hosting scene
  16879. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16880. * @returns a new material
  16881. */
  16882. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16883. }
  16884. }
  16885. declare module BABYLON {
  16886. /** @hidden */
  16887. export var colorPixelShader: {
  16888. name: string;
  16889. shader: string;
  16890. };
  16891. }
  16892. declare module BABYLON {
  16893. /** @hidden */
  16894. export var colorVertexShader: {
  16895. name: string;
  16896. shader: string;
  16897. };
  16898. }
  16899. declare module BABYLON {
  16900. /**
  16901. * Line mesh
  16902. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16903. */
  16904. export class LinesMesh extends Mesh {
  16905. /**
  16906. * If vertex color should be applied to the mesh
  16907. */
  16908. useVertexColor?: boolean | undefined;
  16909. /**
  16910. * If vertex alpha should be applied to the mesh
  16911. */
  16912. useVertexAlpha?: boolean | undefined;
  16913. /**
  16914. * Color of the line (Default: White)
  16915. */
  16916. color: Color3;
  16917. /**
  16918. * Alpha of the line (Default: 1)
  16919. */
  16920. alpha: number;
  16921. /**
  16922. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16923. * This margin is expressed in world space coordinates, so its value may vary.
  16924. * Default value is 0.1
  16925. */
  16926. intersectionThreshold: number;
  16927. private _colorShader;
  16928. /**
  16929. * Creates a new LinesMesh
  16930. * @param name defines the name
  16931. * @param scene defines the hosting scene
  16932. * @param parent defines the parent mesh if any
  16933. * @param source defines the optional source LinesMesh used to clone data from
  16934. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16935. * When false, achieved by calling a clone(), also passing False.
  16936. * This will make creation of children, recursive.
  16937. * @param useVertexColor defines if this LinesMesh supports vertex color
  16938. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16939. */
  16940. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16941. /**
  16942. * If vertex color should be applied to the mesh
  16943. */
  16944. useVertexColor?: boolean | undefined,
  16945. /**
  16946. * If vertex alpha should be applied to the mesh
  16947. */
  16948. useVertexAlpha?: boolean | undefined);
  16949. private _addClipPlaneDefine;
  16950. private _removeClipPlaneDefine;
  16951. isReady(): boolean;
  16952. /**
  16953. * Returns the string "LineMesh"
  16954. */
  16955. getClassName(): string;
  16956. /**
  16957. * @hidden
  16958. */
  16959. /**
  16960. * @hidden
  16961. */
  16962. material: Material;
  16963. /**
  16964. * @hidden
  16965. */
  16966. readonly checkCollisions: boolean;
  16967. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16968. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16969. /**
  16970. * Disposes of the line mesh
  16971. * @param doNotRecurse If children should be disposed
  16972. */
  16973. dispose(doNotRecurse?: boolean): void;
  16974. /**
  16975. * Returns a new LineMesh object cloned from the current one.
  16976. */
  16977. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16978. /**
  16979. * Creates a new InstancedLinesMesh object from the mesh model.
  16980. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16981. * @param name defines the name of the new instance
  16982. * @returns a new InstancedLinesMesh
  16983. */
  16984. createInstance(name: string): InstancedLinesMesh;
  16985. }
  16986. /**
  16987. * Creates an instance based on a source LinesMesh
  16988. */
  16989. export class InstancedLinesMesh extends InstancedMesh {
  16990. /**
  16991. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16992. * This margin is expressed in world space coordinates, so its value may vary.
  16993. * Initilized with the intersectionThreshold value of the source LinesMesh
  16994. */
  16995. intersectionThreshold: number;
  16996. constructor(name: string, source: LinesMesh);
  16997. /**
  16998. * Returns the string "InstancedLinesMesh".
  16999. */
  17000. getClassName(): string;
  17001. }
  17002. }
  17003. declare module BABYLON {
  17004. /** @hidden */
  17005. export var linePixelShader: {
  17006. name: string;
  17007. shader: string;
  17008. };
  17009. }
  17010. declare module BABYLON {
  17011. /** @hidden */
  17012. export var lineVertexShader: {
  17013. name: string;
  17014. shader: string;
  17015. };
  17016. }
  17017. declare module BABYLON {
  17018. interface AbstractMesh {
  17019. /**
  17020. * Disables the mesh edge rendering mode
  17021. * @returns the currentAbstractMesh
  17022. */
  17023. disableEdgesRendering(): AbstractMesh;
  17024. /**
  17025. * Enables the edge rendering mode on the mesh.
  17026. * This mode makes the mesh edges visible
  17027. * @param epsilon defines the maximal distance between two angles to detect a face
  17028. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17029. * @returns the currentAbstractMesh
  17030. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17031. */
  17032. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17033. /**
  17034. * Gets the edgesRenderer associated with the mesh
  17035. */
  17036. edgesRenderer: Nullable<EdgesRenderer>;
  17037. }
  17038. interface LinesMesh {
  17039. /**
  17040. * Enables the edge rendering mode on the mesh.
  17041. * This mode makes the mesh edges visible
  17042. * @param epsilon defines the maximal distance between two angles to detect a face
  17043. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17044. * @returns the currentAbstractMesh
  17045. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17046. */
  17047. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17048. }
  17049. interface InstancedLinesMesh {
  17050. /**
  17051. * Enables the edge rendering mode on the mesh.
  17052. * This mode makes the mesh edges visible
  17053. * @param epsilon defines the maximal distance between two angles to detect a face
  17054. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17055. * @returns the current InstancedLinesMesh
  17056. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17057. */
  17058. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17059. }
  17060. /**
  17061. * Defines the minimum contract an Edges renderer should follow.
  17062. */
  17063. export interface IEdgesRenderer extends IDisposable {
  17064. /**
  17065. * Gets or sets a boolean indicating if the edgesRenderer is active
  17066. */
  17067. isEnabled: boolean;
  17068. /**
  17069. * Renders the edges of the attached mesh,
  17070. */
  17071. render(): void;
  17072. /**
  17073. * Checks wether or not the edges renderer is ready to render.
  17074. * @return true if ready, otherwise false.
  17075. */
  17076. isReady(): boolean;
  17077. }
  17078. /**
  17079. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17080. */
  17081. export class EdgesRenderer implements IEdgesRenderer {
  17082. /**
  17083. * Define the size of the edges with an orthographic camera
  17084. */
  17085. edgesWidthScalerForOrthographic: number;
  17086. /**
  17087. * Define the size of the edges with a perspective camera
  17088. */
  17089. edgesWidthScalerForPerspective: number;
  17090. protected _source: AbstractMesh;
  17091. protected _linesPositions: number[];
  17092. protected _linesNormals: number[];
  17093. protected _linesIndices: number[];
  17094. protected _epsilon: number;
  17095. protected _indicesCount: number;
  17096. protected _lineShader: ShaderMaterial;
  17097. protected _ib: DataBuffer;
  17098. protected _buffers: {
  17099. [key: string]: Nullable<VertexBuffer>;
  17100. };
  17101. protected _checkVerticesInsteadOfIndices: boolean;
  17102. private _meshRebuildObserver;
  17103. private _meshDisposeObserver;
  17104. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17105. isEnabled: boolean;
  17106. /**
  17107. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17108. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17109. * @param source Mesh used to create edges
  17110. * @param epsilon sum of angles in adjacency to check for edge
  17111. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17112. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17113. */
  17114. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17115. protected _prepareRessources(): void;
  17116. /** @hidden */ rebuild(): void;
  17117. /**
  17118. * Releases the required resources for the edges renderer
  17119. */
  17120. dispose(): void;
  17121. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17122. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17123. /**
  17124. * Checks if the pair of p0 and p1 is en edge
  17125. * @param faceIndex
  17126. * @param edge
  17127. * @param faceNormals
  17128. * @param p0
  17129. * @param p1
  17130. * @private
  17131. */
  17132. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17133. /**
  17134. * push line into the position, normal and index buffer
  17135. * @protected
  17136. */
  17137. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17138. /**
  17139. * Generates lines edges from adjacencjes
  17140. * @private
  17141. */ generateEdgesLines(): void;
  17142. /**
  17143. * Checks wether or not the edges renderer is ready to render.
  17144. * @return true if ready, otherwise false.
  17145. */
  17146. isReady(): boolean;
  17147. /**
  17148. * Renders the edges of the attached mesh,
  17149. */
  17150. render(): void;
  17151. }
  17152. /**
  17153. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17154. */
  17155. export class LineEdgesRenderer extends EdgesRenderer {
  17156. /**
  17157. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17158. * @param source LineMesh used to generate edges
  17159. * @param epsilon not important (specified angle for edge detection)
  17160. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17161. */
  17162. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17163. /**
  17164. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17165. */ generateEdgesLines(): void;
  17166. }
  17167. }
  17168. declare module BABYLON {
  17169. /**
  17170. * This represents the object necessary to create a rendering group.
  17171. * This is exclusively used and created by the rendering manager.
  17172. * To modify the behavior, you use the available helpers in your scene or meshes.
  17173. * @hidden
  17174. */
  17175. export class RenderingGroup {
  17176. index: number;
  17177. private _scene;
  17178. private _opaqueSubMeshes;
  17179. private _transparentSubMeshes;
  17180. private _alphaTestSubMeshes;
  17181. private _depthOnlySubMeshes;
  17182. private _particleSystems;
  17183. private _spriteManagers;
  17184. private _opaqueSortCompareFn;
  17185. private _alphaTestSortCompareFn;
  17186. private _transparentSortCompareFn;
  17187. private _renderOpaque;
  17188. private _renderAlphaTest;
  17189. private _renderTransparent;
  17190. /** @hidden */ edgesRenderers: SmartArray<IEdgesRenderer>;
  17191. onBeforeTransparentRendering: () => void;
  17192. /**
  17193. * Set the opaque sort comparison function.
  17194. * If null the sub meshes will be render in the order they were created
  17195. */
  17196. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17197. /**
  17198. * Set the alpha test sort comparison function.
  17199. * If null the sub meshes will be render in the order they were created
  17200. */
  17201. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17202. /**
  17203. * Set the transparent sort comparison function.
  17204. * If null the sub meshes will be render in the order they were created
  17205. */
  17206. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17207. /**
  17208. * Creates a new rendering group.
  17209. * @param index The rendering group index
  17210. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17211. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17212. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17213. */
  17214. 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>);
  17215. /**
  17216. * Render all the sub meshes contained in the group.
  17217. * @param customRenderFunction Used to override the default render behaviour of the group.
  17218. * @returns true if rendered some submeshes.
  17219. */
  17220. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17221. /**
  17222. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17223. * @param subMeshes The submeshes to render
  17224. */
  17225. private renderOpaqueSorted;
  17226. /**
  17227. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17228. * @param subMeshes The submeshes to render
  17229. */
  17230. private renderAlphaTestSorted;
  17231. /**
  17232. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17233. * @param subMeshes The submeshes to render
  17234. */
  17235. private renderTransparentSorted;
  17236. /**
  17237. * Renders the submeshes in a specified order.
  17238. * @param subMeshes The submeshes to sort before render
  17239. * @param sortCompareFn The comparison function use to sort
  17240. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17241. * @param transparent Specifies to activate blending if true
  17242. */
  17243. private static renderSorted;
  17244. /**
  17245. * Renders the submeshes in the order they were dispatched (no sort applied).
  17246. * @param subMeshes The submeshes to render
  17247. */
  17248. private static renderUnsorted;
  17249. /**
  17250. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17251. * are rendered back to front if in the same alpha index.
  17252. *
  17253. * @param a The first submesh
  17254. * @param b The second submesh
  17255. * @returns The result of the comparison
  17256. */
  17257. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17258. /**
  17259. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17260. * are rendered back to front.
  17261. *
  17262. * @param a The first submesh
  17263. * @param b The second submesh
  17264. * @returns The result of the comparison
  17265. */
  17266. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17267. /**
  17268. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17269. * are rendered front to back (prevent overdraw).
  17270. *
  17271. * @param a The first submesh
  17272. * @param b The second submesh
  17273. * @returns The result of the comparison
  17274. */
  17275. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17276. /**
  17277. * Resets the different lists of submeshes to prepare a new frame.
  17278. */
  17279. prepare(): void;
  17280. dispose(): void;
  17281. /**
  17282. * Inserts the submesh in its correct queue depending on its material.
  17283. * @param subMesh The submesh to dispatch
  17284. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17285. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17286. */
  17287. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17288. dispatchSprites(spriteManager: ISpriteManager): void;
  17289. dispatchParticles(particleSystem: IParticleSystem): void;
  17290. private _renderParticles;
  17291. private _renderSprites;
  17292. }
  17293. }
  17294. declare module BABYLON {
  17295. /**
  17296. * Interface describing the different options available in the rendering manager
  17297. * regarding Auto Clear between groups.
  17298. */
  17299. export interface IRenderingManagerAutoClearSetup {
  17300. /**
  17301. * Defines whether or not autoclear is enable.
  17302. */
  17303. autoClear: boolean;
  17304. /**
  17305. * Defines whether or not to autoclear the depth buffer.
  17306. */
  17307. depth: boolean;
  17308. /**
  17309. * Defines whether or not to autoclear the stencil buffer.
  17310. */
  17311. stencil: boolean;
  17312. }
  17313. /**
  17314. * This class is used by the onRenderingGroupObservable
  17315. */
  17316. export class RenderingGroupInfo {
  17317. /**
  17318. * The Scene that being rendered
  17319. */
  17320. scene: Scene;
  17321. /**
  17322. * The camera currently used for the rendering pass
  17323. */
  17324. camera: Nullable<Camera>;
  17325. /**
  17326. * The ID of the renderingGroup being processed
  17327. */
  17328. renderingGroupId: number;
  17329. }
  17330. /**
  17331. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17332. * It is enable to manage the different groups as well as the different necessary sort functions.
  17333. * This should not be used directly aside of the few static configurations
  17334. */
  17335. export class RenderingManager {
  17336. /**
  17337. * The max id used for rendering groups (not included)
  17338. */
  17339. static MAX_RENDERINGGROUPS: number;
  17340. /**
  17341. * The min id used for rendering groups (included)
  17342. */
  17343. static MIN_RENDERINGGROUPS: number;
  17344. /**
  17345. * Used to globally prevent autoclearing scenes.
  17346. */
  17347. static AUTOCLEAR: boolean;
  17348. /**
  17349. * @hidden
  17350. */ useSceneAutoClearSetup: boolean;
  17351. private _scene;
  17352. private _renderingGroups;
  17353. private _depthStencilBufferAlreadyCleaned;
  17354. private _autoClearDepthStencil;
  17355. private _customOpaqueSortCompareFn;
  17356. private _customAlphaTestSortCompareFn;
  17357. private _customTransparentSortCompareFn;
  17358. private _renderingGroupInfo;
  17359. /**
  17360. * Instantiates a new rendering group for a particular scene
  17361. * @param scene Defines the scene the groups belongs to
  17362. */
  17363. constructor(scene: Scene);
  17364. private _clearDepthStencilBuffer;
  17365. /**
  17366. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17367. * @hidden
  17368. */
  17369. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17370. /**
  17371. * Resets the different information of the group to prepare a new frame
  17372. * @hidden
  17373. */
  17374. reset(): void;
  17375. /**
  17376. * Dispose and release the group and its associated resources.
  17377. * @hidden
  17378. */
  17379. dispose(): void;
  17380. /**
  17381. * Clear the info related to rendering groups preventing retention points during dispose.
  17382. */
  17383. freeRenderingGroups(): void;
  17384. private _prepareRenderingGroup;
  17385. /**
  17386. * Add a sprite manager to the rendering manager in order to render it this frame.
  17387. * @param spriteManager Define the sprite manager to render
  17388. */
  17389. dispatchSprites(spriteManager: ISpriteManager): void;
  17390. /**
  17391. * Add a particle system to the rendering manager in order to render it this frame.
  17392. * @param particleSystem Define the particle system to render
  17393. */
  17394. dispatchParticles(particleSystem: IParticleSystem): void;
  17395. /**
  17396. * Add a submesh to the manager in order to render it this frame
  17397. * @param subMesh The submesh to dispatch
  17398. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17399. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17400. */
  17401. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17402. /**
  17403. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17404. * This allowed control for front to back rendering or reversly depending of the special needs.
  17405. *
  17406. * @param renderingGroupId The rendering group id corresponding to its index
  17407. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17408. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17409. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17410. */
  17411. 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;
  17412. /**
  17413. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17414. *
  17415. * @param renderingGroupId The rendering group id corresponding to its index
  17416. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17417. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17418. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17419. */
  17420. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17421. /**
  17422. * Gets the current auto clear configuration for one rendering group of the rendering
  17423. * manager.
  17424. * @param index the rendering group index to get the information for
  17425. * @returns The auto clear setup for the requested rendering group
  17426. */
  17427. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17428. }
  17429. }
  17430. declare module BABYLON {
  17431. /**
  17432. * This Helps creating a texture that will be created from a camera in your scene.
  17433. * It is basically a dynamic texture that could be used to create special effects for instance.
  17434. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17435. */
  17436. export class RenderTargetTexture extends Texture {
  17437. isCube: boolean;
  17438. /**
  17439. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17440. */
  17441. static readonly REFRESHRATE_RENDER_ONCE: number;
  17442. /**
  17443. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17444. */
  17445. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17446. /**
  17447. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17448. * the central point of your effect and can save a lot of performances.
  17449. */
  17450. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17451. /**
  17452. * Use this predicate to dynamically define the list of mesh you want to render.
  17453. * If set, the renderList property will be overwritten.
  17454. */
  17455. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17456. private _renderList;
  17457. /**
  17458. * Use this list to define the list of mesh you want to render.
  17459. */
  17460. renderList: Nullable<Array<AbstractMesh>>;
  17461. private _hookArray;
  17462. /**
  17463. * Define if particles should be rendered in your texture.
  17464. */
  17465. renderParticles: boolean;
  17466. /**
  17467. * Define if sprites should be rendered in your texture.
  17468. */
  17469. renderSprites: boolean;
  17470. /**
  17471. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17472. */
  17473. coordinatesMode: number;
  17474. /**
  17475. * Define the camera used to render the texture.
  17476. */
  17477. activeCamera: Nullable<Camera>;
  17478. /**
  17479. * Override the render function of the texture with your own one.
  17480. */
  17481. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17482. /**
  17483. * Define if camera post processes should be use while rendering the texture.
  17484. */
  17485. useCameraPostProcesses: boolean;
  17486. /**
  17487. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17488. */
  17489. ignoreCameraViewport: boolean;
  17490. private _postProcessManager;
  17491. private _postProcesses;
  17492. private _resizeObserver;
  17493. /**
  17494. * An event triggered when the texture is unbind.
  17495. */
  17496. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17497. /**
  17498. * An event triggered when the texture is unbind.
  17499. */
  17500. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17501. private _onAfterUnbindObserver;
  17502. /**
  17503. * Set a after unbind callback in the texture.
  17504. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17505. */
  17506. onAfterUnbind: () => void;
  17507. /**
  17508. * An event triggered before rendering the texture
  17509. */
  17510. onBeforeRenderObservable: Observable<number>;
  17511. private _onBeforeRenderObserver;
  17512. /**
  17513. * Set a before render callback in the texture.
  17514. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17515. */
  17516. onBeforeRender: (faceIndex: number) => void;
  17517. /**
  17518. * An event triggered after rendering the texture
  17519. */
  17520. onAfterRenderObservable: Observable<number>;
  17521. private _onAfterRenderObserver;
  17522. /**
  17523. * Set a after render callback in the texture.
  17524. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17525. */
  17526. onAfterRender: (faceIndex: number) => void;
  17527. /**
  17528. * An event triggered after the texture clear
  17529. */
  17530. onClearObservable: Observable<Engine>;
  17531. private _onClearObserver;
  17532. /**
  17533. * Set a clear callback in the texture.
  17534. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17535. */
  17536. onClear: (Engine: Engine) => void;
  17537. /**
  17538. * Define the clear color of the Render Target if it should be different from the scene.
  17539. */
  17540. clearColor: Color4;
  17541. protected _size: number | {
  17542. width: number;
  17543. height: number;
  17544. };
  17545. protected _initialSizeParameter: number | {
  17546. width: number;
  17547. height: number;
  17548. } | {
  17549. ratio: number;
  17550. };
  17551. protected _sizeRatio: Nullable<number>;
  17552. /** @hidden */ generateMipMaps: boolean;
  17553. protected _renderingManager: RenderingManager;
  17554. /** @hidden */ waitingRenderList: string[];
  17555. protected _doNotChangeAspectRatio: boolean;
  17556. protected _currentRefreshId: number;
  17557. protected _refreshRate: number;
  17558. protected _textureMatrix: Matrix;
  17559. protected _samples: number;
  17560. protected _renderTargetOptions: RenderTargetCreationOptions;
  17561. /**
  17562. * Gets render target creation options that were used.
  17563. */
  17564. readonly renderTargetOptions: RenderTargetCreationOptions;
  17565. protected _engine: Engine;
  17566. protected _onRatioRescale(): void;
  17567. /**
  17568. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17569. * It must define where the camera used to render the texture is set
  17570. */
  17571. boundingBoxPosition: Vector3;
  17572. private _boundingBoxSize;
  17573. /**
  17574. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17575. * When defined, the cubemap will switch to local mode
  17576. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17577. * @example https://www.babylonjs-playground.com/#RNASML
  17578. */
  17579. boundingBoxSize: Vector3;
  17580. /**
  17581. * In case the RTT has been created with a depth texture, get the associated
  17582. * depth texture.
  17583. * Otherwise, return null.
  17584. */
  17585. depthStencilTexture: Nullable<InternalTexture>;
  17586. /**
  17587. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17588. * or used a shadow, depth texture...
  17589. * @param name The friendly name of the texture
  17590. * @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)
  17591. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17592. * @param generateMipMaps True if mip maps need to be generated after render.
  17593. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17594. * @param type The type of the buffer in the RTT (int, half float, float...)
  17595. * @param isCube True if a cube texture needs to be created
  17596. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17597. * @param generateDepthBuffer True to generate a depth buffer
  17598. * @param generateStencilBuffer True to generate a stencil buffer
  17599. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17600. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17601. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17602. */
  17603. constructor(name: string, size: number | {
  17604. width: number;
  17605. height: number;
  17606. } | {
  17607. ratio: number;
  17608. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17609. /**
  17610. * Creates a depth stencil texture.
  17611. * This is only available in WebGL 2 or with the depth texture extension available.
  17612. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17613. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17614. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17615. */
  17616. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17617. private _processSizeParameter;
  17618. /**
  17619. * Define the number of samples to use in case of MSAA.
  17620. * It defaults to one meaning no MSAA has been enabled.
  17621. */
  17622. samples: number;
  17623. /**
  17624. * Resets the refresh counter of the texture and start bak from scratch.
  17625. * Could be useful to regenerate the texture if it is setup to render only once.
  17626. */
  17627. resetRefreshCounter(): void;
  17628. /**
  17629. * Define the refresh rate of the texture or the rendering frequency.
  17630. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17631. */
  17632. refreshRate: number;
  17633. /**
  17634. * Adds a post process to the render target rendering passes.
  17635. * @param postProcess define the post process to add
  17636. */
  17637. addPostProcess(postProcess: PostProcess): void;
  17638. /**
  17639. * Clear all the post processes attached to the render target
  17640. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17641. */
  17642. clearPostProcesses(dispose?: boolean): void;
  17643. /**
  17644. * Remove one of the post process from the list of attached post processes to the texture
  17645. * @param postProcess define the post process to remove from the list
  17646. */
  17647. removePostProcess(postProcess: PostProcess): void;
  17648. /** @hidden */ shouldRender(): boolean;
  17649. /**
  17650. * Gets the actual render size of the texture.
  17651. * @returns the width of the render size
  17652. */
  17653. getRenderSize(): number;
  17654. /**
  17655. * Gets the actual render width of the texture.
  17656. * @returns the width of the render size
  17657. */
  17658. getRenderWidth(): number;
  17659. /**
  17660. * Gets the actual render height of the texture.
  17661. * @returns the height of the render size
  17662. */
  17663. getRenderHeight(): number;
  17664. /**
  17665. * Get if the texture can be rescaled or not.
  17666. */
  17667. readonly canRescale: boolean;
  17668. /**
  17669. * Resize the texture using a ratio.
  17670. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17671. */
  17672. scale(ratio: number): void;
  17673. /**
  17674. * Get the texture reflection matrix used to rotate/transform the reflection.
  17675. * @returns the reflection matrix
  17676. */
  17677. getReflectionTextureMatrix(): Matrix;
  17678. /**
  17679. * Resize the texture to a new desired size.
  17680. * Be carrefull as it will recreate all the data in the new texture.
  17681. * @param size Define the new size. It can be:
  17682. * - a number for squared texture,
  17683. * - an object containing { width: number, height: number }
  17684. * - or an object containing a ratio { ratio: number }
  17685. */
  17686. resize(size: number | {
  17687. width: number;
  17688. height: number;
  17689. } | {
  17690. ratio: number;
  17691. }): void;
  17692. /**
  17693. * Renders all the objects from the render list into the texture.
  17694. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17695. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17696. */
  17697. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17698. private _bestReflectionRenderTargetDimension;
  17699. /**
  17700. * @hidden
  17701. * @param faceIndex face index to bind to if this is a cubetexture
  17702. */ bindFrameBuffer(faceIndex?: number): void;
  17703. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17704. private renderToTarget;
  17705. /**
  17706. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17707. * This allowed control for front to back rendering or reversly depending of the special needs.
  17708. *
  17709. * @param renderingGroupId The rendering group id corresponding to its index
  17710. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17711. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17712. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17713. */
  17714. 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;
  17715. /**
  17716. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17717. *
  17718. * @param renderingGroupId The rendering group id corresponding to its index
  17719. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17720. */
  17721. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17722. /**
  17723. * Clones the texture.
  17724. * @returns the cloned texture
  17725. */
  17726. clone(): RenderTargetTexture;
  17727. /**
  17728. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17729. * @returns The JSON representation of the texture
  17730. */
  17731. serialize(): any;
  17732. /**
  17733. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17734. */
  17735. disposeFramebufferObjects(): void;
  17736. /**
  17737. * Dispose the texture and release its associated resources.
  17738. */
  17739. dispose(): void;
  17740. /** @hidden */ rebuild(): void;
  17741. /**
  17742. * Clear the info related to rendering groups preventing retention point in material dispose.
  17743. */
  17744. freeRenderingGroups(): void;
  17745. /**
  17746. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17747. * @returns the view count
  17748. */
  17749. getViewCount(): number;
  17750. }
  17751. }
  17752. declare module BABYLON {
  17753. /**
  17754. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17755. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17756. * You can then easily use it as a reflectionTexture on a flat surface.
  17757. * In case the surface is not a plane, please consider relying on reflection probes.
  17758. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17759. */
  17760. export class MirrorTexture extends RenderTargetTexture {
  17761. private scene;
  17762. /**
  17763. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17764. * 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.
  17765. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17766. */
  17767. mirrorPlane: Plane;
  17768. /**
  17769. * Define the blur ratio used to blur the reflection if needed.
  17770. */
  17771. blurRatio: number;
  17772. /**
  17773. * Define the adaptive blur kernel used to blur the reflection if needed.
  17774. * This will autocompute the closest best match for the `blurKernel`
  17775. */
  17776. adaptiveBlurKernel: number;
  17777. /**
  17778. * Define the blur kernel used to blur the reflection if needed.
  17779. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17780. */
  17781. blurKernel: number;
  17782. /**
  17783. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17784. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17785. */
  17786. blurKernelX: number;
  17787. /**
  17788. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17789. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17790. */
  17791. blurKernelY: number;
  17792. private _autoComputeBlurKernel;
  17793. protected _onRatioRescale(): void;
  17794. private _updateGammaSpace;
  17795. private _imageProcessingConfigChangeObserver;
  17796. private _transformMatrix;
  17797. private _mirrorMatrix;
  17798. private _savedViewMatrix;
  17799. private _blurX;
  17800. private _blurY;
  17801. private _adaptiveBlurKernel;
  17802. private _blurKernelX;
  17803. private _blurKernelY;
  17804. private _blurRatio;
  17805. /**
  17806. * Instantiates a Mirror Texture.
  17807. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17808. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17809. * You can then easily use it as a reflectionTexture on a flat surface.
  17810. * In case the surface is not a plane, please consider relying on reflection probes.
  17811. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17812. * @param name
  17813. * @param size
  17814. * @param scene
  17815. * @param generateMipMaps
  17816. * @param type
  17817. * @param samplingMode
  17818. * @param generateDepthBuffer
  17819. */
  17820. constructor(name: string, size: number | {
  17821. width: number;
  17822. height: number;
  17823. } | {
  17824. ratio: number;
  17825. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17826. private _preparePostProcesses;
  17827. /**
  17828. * Clone the mirror texture.
  17829. * @returns the cloned texture
  17830. */
  17831. clone(): MirrorTexture;
  17832. /**
  17833. * Serialize the texture to a JSON representation you could use in Parse later on
  17834. * @returns the serialized JSON representation
  17835. */
  17836. serialize(): any;
  17837. /**
  17838. * Dispose the texture and release its associated resources.
  17839. */
  17840. dispose(): void;
  17841. }
  17842. }
  17843. declare module BABYLON {
  17844. /**
  17845. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17846. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17847. */
  17848. export class Texture extends BaseTexture {
  17849. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17850. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17851. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17852. /** nearest is mag = nearest and min = nearest and mip = linear */
  17853. static readonly NEAREST_SAMPLINGMODE: number;
  17854. /** nearest is mag = nearest and min = nearest and mip = linear */
  17855. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17856. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17857. static readonly BILINEAR_SAMPLINGMODE: number;
  17858. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17859. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17860. /** Trilinear is mag = linear and min = linear and mip = linear */
  17861. static readonly TRILINEAR_SAMPLINGMODE: number;
  17862. /** Trilinear is mag = linear and min = linear and mip = linear */
  17863. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17864. /** mag = nearest and min = nearest and mip = nearest */
  17865. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17866. /** mag = nearest and min = linear and mip = nearest */
  17867. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17868. /** mag = nearest and min = linear and mip = linear */
  17869. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17870. /** mag = nearest and min = linear and mip = none */
  17871. static readonly NEAREST_LINEAR: number;
  17872. /** mag = nearest and min = nearest and mip = none */
  17873. static readonly NEAREST_NEAREST: number;
  17874. /** mag = linear and min = nearest and mip = nearest */
  17875. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17876. /** mag = linear and min = nearest and mip = linear */
  17877. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17878. /** mag = linear and min = linear and mip = none */
  17879. static readonly LINEAR_LINEAR: number;
  17880. /** mag = linear and min = nearest and mip = none */
  17881. static readonly LINEAR_NEAREST: number;
  17882. /** Explicit coordinates mode */
  17883. static readonly EXPLICIT_MODE: number;
  17884. /** Spherical coordinates mode */
  17885. static readonly SPHERICAL_MODE: number;
  17886. /** Planar coordinates mode */
  17887. static readonly PLANAR_MODE: number;
  17888. /** Cubic coordinates mode */
  17889. static readonly CUBIC_MODE: number;
  17890. /** Projection coordinates mode */
  17891. static readonly PROJECTION_MODE: number;
  17892. /** Inverse Cubic coordinates mode */
  17893. static readonly SKYBOX_MODE: number;
  17894. /** Inverse Cubic coordinates mode */
  17895. static readonly INVCUBIC_MODE: number;
  17896. /** Equirectangular coordinates mode */
  17897. static readonly EQUIRECTANGULAR_MODE: number;
  17898. /** Equirectangular Fixed coordinates mode */
  17899. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17900. /** Equirectangular Fixed Mirrored coordinates mode */
  17901. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17902. /** Texture is not repeating outside of 0..1 UVs */
  17903. static readonly CLAMP_ADDRESSMODE: number;
  17904. /** Texture is repeating outside of 0..1 UVs */
  17905. static readonly WRAP_ADDRESSMODE: number;
  17906. /** Texture is repeating and mirrored */
  17907. static readonly MIRROR_ADDRESSMODE: number;
  17908. /**
  17909. * 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
  17910. */
  17911. static UseSerializedUrlIfAny: boolean;
  17912. /**
  17913. * Define the url of the texture.
  17914. */
  17915. url: Nullable<string>;
  17916. /**
  17917. * Define an offset on the texture to offset the u coordinates of the UVs
  17918. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17919. */
  17920. uOffset: number;
  17921. /**
  17922. * Define an offset on the texture to offset the v coordinates of the UVs
  17923. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17924. */
  17925. vOffset: number;
  17926. /**
  17927. * Define an offset on the texture to scale the u coordinates of the UVs
  17928. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17929. */
  17930. uScale: number;
  17931. /**
  17932. * Define an offset on the texture to scale the v coordinates of the UVs
  17933. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17934. */
  17935. vScale: number;
  17936. /**
  17937. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17938. * @see http://doc.babylonjs.com/how_to/more_materials
  17939. */
  17940. uAng: number;
  17941. /**
  17942. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17943. * @see http://doc.babylonjs.com/how_to/more_materials
  17944. */
  17945. vAng: number;
  17946. /**
  17947. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17948. * @see http://doc.babylonjs.com/how_to/more_materials
  17949. */
  17950. wAng: number;
  17951. /**
  17952. * Defines the center of rotation (U)
  17953. */
  17954. uRotationCenter: number;
  17955. /**
  17956. * Defines the center of rotation (V)
  17957. */
  17958. vRotationCenter: number;
  17959. /**
  17960. * Defines the center of rotation (W)
  17961. */
  17962. wRotationCenter: number;
  17963. /**
  17964. * Are mip maps generated for this texture or not.
  17965. */
  17966. readonly noMipmap: boolean;
  17967. /**
  17968. * List of inspectable custom properties (used by the Inspector)
  17969. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17970. */
  17971. inspectableCustomProperties: Nullable<IInspectable[]>;
  17972. private _noMipmap;
  17973. /** @hidden */ invertY: boolean;
  17974. private _rowGenerationMatrix;
  17975. private _cachedTextureMatrix;
  17976. private _projectionModeMatrix;
  17977. private _t0;
  17978. private _t1;
  17979. private _t2;
  17980. private _cachedUOffset;
  17981. private _cachedVOffset;
  17982. private _cachedUScale;
  17983. private _cachedVScale;
  17984. private _cachedUAng;
  17985. private _cachedVAng;
  17986. private _cachedWAng;
  17987. private _cachedProjectionMatrixId;
  17988. private _cachedCoordinatesMode;
  17989. /** @hidden */
  17990. protected _initialSamplingMode: number;
  17991. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17992. private _deleteBuffer;
  17993. protected _format: Nullable<number>;
  17994. private _delayedOnLoad;
  17995. private _delayedOnError;
  17996. /**
  17997. * Observable triggered once the texture has been loaded.
  17998. */
  17999. onLoadObservable: Observable<Texture>;
  18000. protected _isBlocking: boolean;
  18001. /**
  18002. * Is the texture preventing material to render while loading.
  18003. * If false, a default texture will be used instead of the loading one during the preparation step.
  18004. */
  18005. isBlocking: boolean;
  18006. /**
  18007. * Get the current sampling mode associated with the texture.
  18008. */
  18009. readonly samplingMode: number;
  18010. /**
  18011. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18012. */
  18013. readonly invertY: boolean;
  18014. /**
  18015. * Instantiates a new texture.
  18016. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18017. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18018. * @param url define the url of the picture to load as a texture
  18019. * @param scene define the scene the texture will belong to
  18020. * @param noMipmap define if the texture will require mip maps or not
  18021. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18022. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18023. * @param onLoad define a callback triggered when the texture has been loaded
  18024. * @param onError define a callback triggered when an error occurred during the loading session
  18025. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18026. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18027. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18028. */
  18029. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18030. /**
  18031. * Update the url (and optional buffer) of this texture if url was null during construction.
  18032. * @param url the url of the texture
  18033. * @param buffer the buffer of the texture (defaults to null)
  18034. * @param onLoad callback called when the texture is loaded (defaults to null)
  18035. */
  18036. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18037. /**
  18038. * Finish the loading sequence of a texture flagged as delayed load.
  18039. * @hidden
  18040. */
  18041. delayLoad(): void;
  18042. private _prepareRowForTextureGeneration;
  18043. /**
  18044. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18045. * @returns the transform matrix of the texture.
  18046. */
  18047. getTextureMatrix(): Matrix;
  18048. /**
  18049. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18050. * @returns The reflection texture transform
  18051. */
  18052. getReflectionTextureMatrix(): Matrix;
  18053. /**
  18054. * Clones the texture.
  18055. * @returns the cloned texture
  18056. */
  18057. clone(): Texture;
  18058. /**
  18059. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18060. * @returns The JSON representation of the texture
  18061. */
  18062. serialize(): any;
  18063. /**
  18064. * Get the current class name of the texture useful for serialization or dynamic coding.
  18065. * @returns "Texture"
  18066. */
  18067. getClassName(): string;
  18068. /**
  18069. * Dispose the texture and release its associated resources.
  18070. */
  18071. dispose(): void;
  18072. /**
  18073. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18074. * @param parsedTexture Define the JSON representation of the texture
  18075. * @param scene Define the scene the parsed texture should be instantiated in
  18076. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18077. * @returns The parsed texture if successful
  18078. */
  18079. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18080. /**
  18081. * Creates a texture from its base 64 representation.
  18082. * @param data Define the base64 payload without the data: prefix
  18083. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18084. * @param scene Define the scene the texture should belong to
  18085. * @param noMipmap Forces the texture to not create mip map information if true
  18086. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18087. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18088. * @param onLoad define a callback triggered when the texture has been loaded
  18089. * @param onError define a callback triggered when an error occurred during the loading session
  18090. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18091. * @returns the created texture
  18092. */
  18093. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18094. /**
  18095. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18096. * @param data Define the base64 payload without the data: prefix
  18097. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18098. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18099. * @param scene Define the scene the texture should belong to
  18100. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18101. * @param noMipmap Forces the texture to not create mip map information if true
  18102. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18103. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18104. * @param onLoad define a callback triggered when the texture has been loaded
  18105. * @param onError define a callback triggered when an error occurred during the loading session
  18106. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18107. * @returns the created texture
  18108. */
  18109. 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;
  18110. }
  18111. }
  18112. declare module BABYLON {
  18113. interface Engine {
  18114. /**
  18115. * Creates a raw texture
  18116. * @param data defines the data to store in the texture
  18117. * @param width defines the width of the texture
  18118. * @param height defines the height of the texture
  18119. * @param format defines the format of the data
  18120. * @param generateMipMaps defines if the engine should generate the mip levels
  18121. * @param invertY defines if data must be stored with Y axis inverted
  18122. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18123. * @param compression defines the compression used (null by default)
  18124. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18125. * @returns the raw texture inside an InternalTexture
  18126. */
  18127. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18128. /**
  18129. * Update a raw texture
  18130. * @param texture defines the texture to update
  18131. * @param data defines the data to store in the texture
  18132. * @param format defines the format of the data
  18133. * @param invertY defines if data must be stored with Y axis inverted
  18134. */
  18135. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18136. /**
  18137. * Update a raw texture
  18138. * @param texture defines the texture to update
  18139. * @param data defines the data to store in the texture
  18140. * @param format defines the format of the data
  18141. * @param invertY defines if data must be stored with Y axis inverted
  18142. * @param compression defines the compression used (null by default)
  18143. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18144. */
  18145. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18146. /**
  18147. * Creates a new raw cube texture
  18148. * @param data defines the array of data to use to create each face
  18149. * @param size defines the size of the textures
  18150. * @param format defines the format of the data
  18151. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18152. * @param generateMipMaps defines if the engine should generate the mip levels
  18153. * @param invertY defines if data must be stored with Y axis inverted
  18154. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18155. * @param compression defines the compression used (null by default)
  18156. * @returns the cube texture as an InternalTexture
  18157. */
  18158. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18159. /**
  18160. * Update a raw cube texture
  18161. * @param texture defines the texture to udpdate
  18162. * @param data defines the data to store
  18163. * @param format defines the data format
  18164. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18165. * @param invertY defines if data must be stored with Y axis inverted
  18166. */
  18167. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18168. /**
  18169. * Update a raw cube texture
  18170. * @param texture defines the texture to udpdate
  18171. * @param data defines the data to store
  18172. * @param format defines the data format
  18173. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18174. * @param invertY defines if data must be stored with Y axis inverted
  18175. * @param compression defines the compression used (null by default)
  18176. */
  18177. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18178. /**
  18179. * Update a raw cube texture
  18180. * @param texture defines the texture to udpdate
  18181. * @param data defines the data to store
  18182. * @param format defines the data format
  18183. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18184. * @param invertY defines if data must be stored with Y axis inverted
  18185. * @param compression defines the compression used (null by default)
  18186. * @param level defines which level of the texture to update
  18187. */
  18188. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18189. /**
  18190. * Creates a new raw cube texture from a specified url
  18191. * @param url defines the url where the data is located
  18192. * @param scene defines the current scene
  18193. * @param size defines the size of the textures
  18194. * @param format defines the format of the data
  18195. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18196. * @param noMipmap defines if the engine should avoid generating the mip levels
  18197. * @param callback defines a callback used to extract texture data from loaded data
  18198. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18199. * @param onLoad defines a callback called when texture is loaded
  18200. * @param onError defines a callback called if there is an error
  18201. * @returns the cube texture as an InternalTexture
  18202. */
  18203. 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;
  18204. /**
  18205. * Creates a new raw cube texture from a specified url
  18206. * @param url defines the url where the data is located
  18207. * @param scene defines the current scene
  18208. * @param size defines the size of the textures
  18209. * @param format defines the format of the data
  18210. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18211. * @param noMipmap defines if the engine should avoid generating the mip levels
  18212. * @param callback defines a callback used to extract texture data from loaded data
  18213. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18214. * @param onLoad defines a callback called when texture is loaded
  18215. * @param onError defines a callback called if there is an error
  18216. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18217. * @param invertY defines if data must be stored with Y axis inverted
  18218. * @returns the cube texture as an InternalTexture
  18219. */
  18220. 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;
  18221. /**
  18222. * Creates a new raw 3D texture
  18223. * @param data defines the data used to create the texture
  18224. * @param width defines the width of the texture
  18225. * @param height defines the height of the texture
  18226. * @param depth defines the depth of the texture
  18227. * @param format defines the format of the texture
  18228. * @param generateMipMaps defines if the engine must generate mip levels
  18229. * @param invertY defines if data must be stored with Y axis inverted
  18230. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18231. * @param compression defines the compressed used (can be null)
  18232. * @param textureType defines the compressed used (can be null)
  18233. * @returns a new raw 3D texture (stored in an InternalTexture)
  18234. */
  18235. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18236. /**
  18237. * Update a raw 3D texture
  18238. * @param texture defines the texture to update
  18239. * @param data defines the data to store
  18240. * @param format defines the data format
  18241. * @param invertY defines if data must be stored with Y axis inverted
  18242. */
  18243. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18244. /**
  18245. * Update a raw 3D texture
  18246. * @param texture defines the texture to update
  18247. * @param data defines the data to store
  18248. * @param format defines the data format
  18249. * @param invertY defines if data must be stored with Y axis inverted
  18250. * @param compression defines the used compression (can be null)
  18251. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18252. */
  18253. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18254. }
  18255. }
  18256. declare module BABYLON {
  18257. /**
  18258. * Raw texture can help creating a texture directly from an array of data.
  18259. * This can be super useful if you either get the data from an uncompressed source or
  18260. * if you wish to create your texture pixel by pixel.
  18261. */
  18262. export class RawTexture extends Texture {
  18263. /**
  18264. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18265. */
  18266. format: number;
  18267. private _engine;
  18268. /**
  18269. * Instantiates a new RawTexture.
  18270. * Raw texture can help creating a texture directly from an array of data.
  18271. * This can be super useful if you either get the data from an uncompressed source or
  18272. * if you wish to create your texture pixel by pixel.
  18273. * @param data define the array of data to use to create the texture
  18274. * @param width define the width of the texture
  18275. * @param height define the height of the texture
  18276. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18277. * @param scene define the scene the texture belongs to
  18278. * @param generateMipMaps define whether mip maps should be generated or not
  18279. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18280. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18281. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18282. */
  18283. constructor(data: ArrayBufferView, width: number, height: number,
  18284. /**
  18285. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18286. */
  18287. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18288. /**
  18289. * Updates the texture underlying data.
  18290. * @param data Define the new data of the texture
  18291. */
  18292. update(data: ArrayBufferView): void;
  18293. /**
  18294. * Creates a luminance texture from some data.
  18295. * @param data Define the texture data
  18296. * @param width Define the width of the texture
  18297. * @param height Define the height of the texture
  18298. * @param scene Define the scene the texture belongs to
  18299. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18300. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18301. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18302. * @returns the luminance texture
  18303. */
  18304. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18305. /**
  18306. * Creates a luminance alpha texture from some data.
  18307. * @param data Define the texture data
  18308. * @param width Define the width of the texture
  18309. * @param height Define the height of the texture
  18310. * @param scene Define the scene the texture belongs to
  18311. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18312. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18313. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18314. * @returns the luminance alpha texture
  18315. */
  18316. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18317. /**
  18318. * Creates an alpha texture from some data.
  18319. * @param data Define the texture data
  18320. * @param width Define the width of the texture
  18321. * @param height Define the height of the texture
  18322. * @param scene Define the scene the texture belongs to
  18323. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18324. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18325. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18326. * @returns the alpha texture
  18327. */
  18328. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18329. /**
  18330. * Creates a RGB texture from some data.
  18331. * @param data Define the texture data
  18332. * @param width Define the width of the texture
  18333. * @param height Define the height of the texture
  18334. * @param scene Define the scene the texture belongs to
  18335. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18336. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18337. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18338. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18339. * @returns the RGB alpha texture
  18340. */
  18341. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18342. /**
  18343. * Creates a RGBA texture from some data.
  18344. * @param data Define the texture data
  18345. * @param width Define the width of the texture
  18346. * @param height Define the height of the texture
  18347. * @param scene Define the scene the texture belongs to
  18348. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18349. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18350. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18351. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18352. * @returns the RGBA texture
  18353. */
  18354. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18355. /**
  18356. * Creates a R texture from some data.
  18357. * @param data Define the texture data
  18358. * @param width Define the width of the texture
  18359. * @param height Define the height of the texture
  18360. * @param scene Define the scene the texture belongs to
  18361. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18362. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18363. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18364. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18365. * @returns the R texture
  18366. */
  18367. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18368. }
  18369. }
  18370. declare module BABYLON {
  18371. /**
  18372. * Defines a runtime animation
  18373. */
  18374. export class RuntimeAnimation {
  18375. private _events;
  18376. /**
  18377. * The current frame of the runtime animation
  18378. */
  18379. private _currentFrame;
  18380. /**
  18381. * The animation used by the runtime animation
  18382. */
  18383. private _animation;
  18384. /**
  18385. * The target of the runtime animation
  18386. */
  18387. private _target;
  18388. /**
  18389. * The initiating animatable
  18390. */
  18391. private _host;
  18392. /**
  18393. * The original value of the runtime animation
  18394. */
  18395. private _originalValue;
  18396. /**
  18397. * The original blend value of the runtime animation
  18398. */
  18399. private _originalBlendValue;
  18400. /**
  18401. * The offsets cache of the runtime animation
  18402. */
  18403. private _offsetsCache;
  18404. /**
  18405. * The high limits cache of the runtime animation
  18406. */
  18407. private _highLimitsCache;
  18408. /**
  18409. * Specifies if the runtime animation has been stopped
  18410. */
  18411. private _stopped;
  18412. /**
  18413. * The blending factor of the runtime animation
  18414. */
  18415. private _blendingFactor;
  18416. /**
  18417. * The BabylonJS scene
  18418. */
  18419. private _scene;
  18420. /**
  18421. * The current value of the runtime animation
  18422. */
  18423. private _currentValue;
  18424. /** @hidden */ animationState: _IAnimationState;
  18425. /**
  18426. * The active target of the runtime animation
  18427. */
  18428. private _activeTargets;
  18429. private _currentActiveTarget;
  18430. private _directTarget;
  18431. /**
  18432. * The target path of the runtime animation
  18433. */
  18434. private _targetPath;
  18435. /**
  18436. * The weight of the runtime animation
  18437. */
  18438. private _weight;
  18439. /**
  18440. * The ratio offset of the runtime animation
  18441. */
  18442. private _ratioOffset;
  18443. /**
  18444. * The previous delay of the runtime animation
  18445. */
  18446. private _previousDelay;
  18447. /**
  18448. * The previous ratio of the runtime animation
  18449. */
  18450. private _previousRatio;
  18451. private _enableBlending;
  18452. private _keys;
  18453. private _minFrame;
  18454. private _maxFrame;
  18455. private _minValue;
  18456. private _maxValue;
  18457. private _targetIsArray;
  18458. /**
  18459. * Gets the current frame of the runtime animation
  18460. */
  18461. readonly currentFrame: number;
  18462. /**
  18463. * Gets the weight of the runtime animation
  18464. */
  18465. readonly weight: number;
  18466. /**
  18467. * Gets the current value of the runtime animation
  18468. */
  18469. readonly currentValue: any;
  18470. /**
  18471. * Gets the target path of the runtime animation
  18472. */
  18473. readonly targetPath: string;
  18474. /**
  18475. * Gets the actual target of the runtime animation
  18476. */
  18477. readonly target: any;
  18478. /** @hidden */ onLoop: () => void;
  18479. /**
  18480. * Create a new RuntimeAnimation object
  18481. * @param target defines the target of the animation
  18482. * @param animation defines the source animation object
  18483. * @param scene defines the hosting scene
  18484. * @param host defines the initiating Animatable
  18485. */
  18486. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18487. private _preparePath;
  18488. /**
  18489. * Gets the animation from the runtime animation
  18490. */
  18491. readonly animation: Animation;
  18492. /**
  18493. * Resets the runtime animation to the beginning
  18494. * @param restoreOriginal defines whether to restore the target property to the original value
  18495. */
  18496. reset(restoreOriginal?: boolean): void;
  18497. /**
  18498. * Specifies if the runtime animation is stopped
  18499. * @returns Boolean specifying if the runtime animation is stopped
  18500. */
  18501. isStopped(): boolean;
  18502. /**
  18503. * Disposes of the runtime animation
  18504. */
  18505. dispose(): void;
  18506. /**
  18507. * Apply the interpolated value to the target
  18508. * @param currentValue defines the value computed by the animation
  18509. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18510. */
  18511. setValue(currentValue: any, weight: number): void;
  18512. private _getOriginalValues;
  18513. private _setValue;
  18514. /**
  18515. * Gets the loop pmode of the runtime animation
  18516. * @returns Loop Mode
  18517. */
  18518. private _getCorrectLoopMode;
  18519. /**
  18520. * Move the current animation to a given frame
  18521. * @param frame defines the frame to move to
  18522. */
  18523. goToFrame(frame: number): void;
  18524. /**
  18525. * @hidden Internal use only
  18526. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18527. /**
  18528. * Execute the current animation
  18529. * @param delay defines the delay to add to the current frame
  18530. * @param from defines the lower bound of the animation range
  18531. * @param to defines the upper bound of the animation range
  18532. * @param loop defines if the current animation must loop
  18533. * @param speedRatio defines the current speed ratio
  18534. * @param weight defines the weight of the animation (default is -1 so no weight)
  18535. * @param onLoop optional callback called when animation loops
  18536. * @returns a boolean indicating if the animation is running
  18537. */
  18538. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18539. }
  18540. }
  18541. declare module BABYLON {
  18542. /**
  18543. * Class used to store an actual running animation
  18544. */
  18545. export class Animatable {
  18546. /** defines the target object */
  18547. target: any;
  18548. /** defines the starting frame number (default is 0) */
  18549. fromFrame: number;
  18550. /** defines the ending frame number (default is 100) */
  18551. toFrame: number;
  18552. /** defines if the animation must loop (default is false) */
  18553. loopAnimation: boolean;
  18554. /** defines a callback to call when animation ends if it is not looping */
  18555. onAnimationEnd?: (() => void) | null | undefined;
  18556. /** defines a callback to call when animation loops */
  18557. onAnimationLoop?: (() => void) | null | undefined;
  18558. private _localDelayOffset;
  18559. private _pausedDelay;
  18560. private _runtimeAnimations;
  18561. private _paused;
  18562. private _scene;
  18563. private _speedRatio;
  18564. private _weight;
  18565. private _syncRoot;
  18566. /**
  18567. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18568. * This will only apply for non looping animation (default is true)
  18569. */
  18570. disposeOnEnd: boolean;
  18571. /**
  18572. * Gets a boolean indicating if the animation has started
  18573. */
  18574. animationStarted: boolean;
  18575. /**
  18576. * Observer raised when the animation ends
  18577. */
  18578. onAnimationEndObservable: Observable<Animatable>;
  18579. /**
  18580. * Observer raised when the animation loops
  18581. */
  18582. onAnimationLoopObservable: Observable<Animatable>;
  18583. /**
  18584. * Gets the root Animatable used to synchronize and normalize animations
  18585. */
  18586. readonly syncRoot: Nullable<Animatable>;
  18587. /**
  18588. * Gets the current frame of the first RuntimeAnimation
  18589. * Used to synchronize Animatables
  18590. */
  18591. readonly masterFrame: number;
  18592. /**
  18593. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18594. */
  18595. weight: number;
  18596. /**
  18597. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18598. */
  18599. speedRatio: number;
  18600. /**
  18601. * Creates a new Animatable
  18602. * @param scene defines the hosting scene
  18603. * @param target defines the target object
  18604. * @param fromFrame defines the starting frame number (default is 0)
  18605. * @param toFrame defines the ending frame number (default is 100)
  18606. * @param loopAnimation defines if the animation must loop (default is false)
  18607. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18608. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18609. * @param animations defines a group of animation to add to the new Animatable
  18610. * @param onAnimationLoop defines a callback to call when animation loops
  18611. */
  18612. constructor(scene: Scene,
  18613. /** defines the target object */
  18614. target: any,
  18615. /** defines the starting frame number (default is 0) */
  18616. fromFrame?: number,
  18617. /** defines the ending frame number (default is 100) */
  18618. toFrame?: number,
  18619. /** defines if the animation must loop (default is false) */
  18620. loopAnimation?: boolean, speedRatio?: number,
  18621. /** defines a callback to call when animation ends if it is not looping */
  18622. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18623. /** defines a callback to call when animation loops */
  18624. onAnimationLoop?: (() => void) | null | undefined);
  18625. /**
  18626. * Synchronize and normalize current Animatable with a source Animatable
  18627. * This is useful when using animation weights and when animations are not of the same length
  18628. * @param root defines the root Animatable to synchronize with
  18629. * @returns the current Animatable
  18630. */
  18631. syncWith(root: Animatable): Animatable;
  18632. /**
  18633. * Gets the list of runtime animations
  18634. * @returns an array of RuntimeAnimation
  18635. */
  18636. getAnimations(): RuntimeAnimation[];
  18637. /**
  18638. * Adds more animations to the current animatable
  18639. * @param target defines the target of the animations
  18640. * @param animations defines the new animations to add
  18641. */
  18642. appendAnimations(target: any, animations: Animation[]): void;
  18643. /**
  18644. * Gets the source animation for a specific property
  18645. * @param property defines the propertyu to look for
  18646. * @returns null or the source animation for the given property
  18647. */
  18648. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18649. /**
  18650. * Gets the runtime animation for a specific property
  18651. * @param property defines the propertyu to look for
  18652. * @returns null or the runtime animation for the given property
  18653. */
  18654. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18655. /**
  18656. * Resets the animatable to its original state
  18657. */
  18658. reset(): void;
  18659. /**
  18660. * Allows the animatable to blend with current running animations
  18661. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18662. * @param blendingSpeed defines the blending speed to use
  18663. */
  18664. enableBlending(blendingSpeed: number): void;
  18665. /**
  18666. * Disable animation blending
  18667. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18668. */
  18669. disableBlending(): void;
  18670. /**
  18671. * Jump directly to a given frame
  18672. * @param frame defines the frame to jump to
  18673. */
  18674. goToFrame(frame: number): void;
  18675. /**
  18676. * Pause the animation
  18677. */
  18678. pause(): void;
  18679. /**
  18680. * Restart the animation
  18681. */
  18682. restart(): void;
  18683. private _raiseOnAnimationEnd;
  18684. /**
  18685. * Stop and delete the current animation
  18686. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18687. * @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)
  18688. */
  18689. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18690. /**
  18691. * Wait asynchronously for the animation to end
  18692. * @returns a promise which will be fullfilled when the animation ends
  18693. */
  18694. waitAsync(): Promise<Animatable>;
  18695. /** @hidden */ animate(delay: number): boolean;
  18696. }
  18697. interface Scene {
  18698. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18699. /** @hidden */ processLateAnimationBindingsForMatrices(holder: {
  18700. totalWeight: number;
  18701. animations: RuntimeAnimation[];
  18702. originalValue: Matrix;
  18703. }): any;
  18704. /** @hidden */ processLateAnimationBindingsForQuaternions(holder: {
  18705. totalWeight: number;
  18706. animations: RuntimeAnimation[];
  18707. originalValue: Quaternion;
  18708. }, refQuaternion: Quaternion): Quaternion;
  18709. /** @hidden */ processLateAnimationBindings(): void;
  18710. /**
  18711. * Will start the animation sequence of a given target
  18712. * @param target defines the target
  18713. * @param from defines from which frame should animation start
  18714. * @param to defines until which frame should animation run.
  18715. * @param weight defines the weight to apply to the animation (1.0 by default)
  18716. * @param loop defines if the animation loops
  18717. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18718. * @param onAnimationEnd defines the function to be executed when the animation ends
  18719. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18720. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18721. * @param onAnimationLoop defines the callback to call when an animation loops
  18722. * @returns the animatable object created for this animation
  18723. */
  18724. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18725. /**
  18726. * Will start the animation sequence of a given target
  18727. * @param target defines the target
  18728. * @param from defines from which frame should animation start
  18729. * @param to defines until which frame should animation run.
  18730. * @param loop defines if the animation loops
  18731. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18732. * @param onAnimationEnd defines the function to be executed when the animation ends
  18733. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18734. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18735. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18736. * @param onAnimationLoop defines the callback to call when an animation loops
  18737. * @returns the animatable object created for this animation
  18738. */
  18739. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18740. /**
  18741. * Will start the animation sequence of a given target and its hierarchy
  18742. * @param target defines the target
  18743. * @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.
  18744. * @param from defines from which frame should animation start
  18745. * @param to defines until which frame should animation run.
  18746. * @param loop defines if the animation loops
  18747. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18748. * @param onAnimationEnd defines the function to be executed when the animation ends
  18749. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18750. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18751. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18752. * @param onAnimationLoop defines the callback to call when an animation loops
  18753. * @returns the list of created animatables
  18754. */
  18755. 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[];
  18756. /**
  18757. * Begin a new animation on a given node
  18758. * @param target defines the target where the animation will take place
  18759. * @param animations defines the list of animations to start
  18760. * @param from defines the initial value
  18761. * @param to defines the final value
  18762. * @param loop defines if you want animation to loop (off by default)
  18763. * @param speedRatio defines the speed ratio to apply to all animations
  18764. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18765. * @param onAnimationLoop defines the callback to call when an animation loops
  18766. * @returns the list of created animatables
  18767. */
  18768. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18769. /**
  18770. * Begin a new animation on a given node and its hierarchy
  18771. * @param target defines the root node where the animation will take place
  18772. * @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.
  18773. * @param animations defines the list of animations to start
  18774. * @param from defines the initial value
  18775. * @param to defines the final value
  18776. * @param loop defines if you want animation to loop (off by default)
  18777. * @param speedRatio defines the speed ratio to apply to all animations
  18778. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18779. * @param onAnimationLoop defines the callback to call when an animation loops
  18780. * @returns the list of animatables created for all nodes
  18781. */
  18782. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18783. /**
  18784. * Gets the animatable associated with a specific target
  18785. * @param target defines the target of the animatable
  18786. * @returns the required animatable if found
  18787. */
  18788. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18789. /**
  18790. * Gets all animatables associated with a given target
  18791. * @param target defines the target to look animatables for
  18792. * @returns an array of Animatables
  18793. */
  18794. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18795. /**
  18796. * Will stop the animation of the given target
  18797. * @param target - the target
  18798. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18799. * @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)
  18800. */
  18801. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18802. /**
  18803. * Stops and removes all animations that have been applied to the scene
  18804. */
  18805. stopAllAnimations(): void;
  18806. }
  18807. interface Bone {
  18808. /**
  18809. * Copy an animation range from another bone
  18810. * @param source defines the source bone
  18811. * @param rangeName defines the range name to copy
  18812. * @param frameOffset defines the frame offset
  18813. * @param rescaleAsRequired defines if rescaling must be applied if required
  18814. * @param skelDimensionsRatio defines the scaling ratio
  18815. * @returns true if operation was successful
  18816. */
  18817. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18818. }
  18819. }
  18820. declare module BABYLON {
  18821. /**
  18822. * Class used to handle skinning animations
  18823. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18824. */
  18825. export class Skeleton implements IAnimatable {
  18826. /** defines the skeleton name */
  18827. name: string;
  18828. /** defines the skeleton Id */
  18829. id: string;
  18830. /**
  18831. * Defines the list of child bones
  18832. */
  18833. bones: Bone[];
  18834. /**
  18835. * Defines an estimate of the dimension of the skeleton at rest
  18836. */
  18837. dimensionsAtRest: Vector3;
  18838. /**
  18839. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18840. */
  18841. needInitialSkinMatrix: boolean;
  18842. /**
  18843. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18844. */
  18845. overrideMesh: Nullable<AbstractMesh>;
  18846. /**
  18847. * Gets the list of animations attached to this skeleton
  18848. */
  18849. animations: Array<Animation>;
  18850. private _scene;
  18851. private _isDirty;
  18852. private _transformMatrices;
  18853. private _transformMatrixTexture;
  18854. private _meshesWithPoseMatrix;
  18855. private _animatables;
  18856. private _identity;
  18857. private _synchronizedWithMesh;
  18858. private _ranges;
  18859. private _lastAbsoluteTransformsUpdateId;
  18860. private _canUseTextureForBones;
  18861. private _uniqueId;
  18862. /** @hidden */ numBonesWithLinkedTransformNode: number;
  18863. /**
  18864. * Specifies if the skeleton should be serialized
  18865. */
  18866. doNotSerialize: boolean;
  18867. private _useTextureToStoreBoneMatrices;
  18868. /**
  18869. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18870. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18871. */
  18872. useTextureToStoreBoneMatrices: boolean;
  18873. private _animationPropertiesOverride;
  18874. /**
  18875. * Gets or sets the animation properties override
  18876. */
  18877. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18878. /**
  18879. * List of inspectable custom properties (used by the Inspector)
  18880. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18881. */
  18882. inspectableCustomProperties: IInspectable[];
  18883. /**
  18884. * An observable triggered before computing the skeleton's matrices
  18885. */
  18886. onBeforeComputeObservable: Observable<Skeleton>;
  18887. /**
  18888. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18889. */
  18890. readonly isUsingTextureForMatrices: boolean;
  18891. /**
  18892. * Gets the unique ID of this skeleton
  18893. */
  18894. readonly uniqueId: number;
  18895. /**
  18896. * Creates a new skeleton
  18897. * @param name defines the skeleton name
  18898. * @param id defines the skeleton Id
  18899. * @param scene defines the hosting scene
  18900. */
  18901. constructor(
  18902. /** defines the skeleton name */
  18903. name: string,
  18904. /** defines the skeleton Id */
  18905. id: string, scene: Scene);
  18906. /**
  18907. * Gets the current object class name.
  18908. * @return the class name
  18909. */
  18910. getClassName(): string;
  18911. /**
  18912. * Returns an array containing the root bones
  18913. * @returns an array containing the root bones
  18914. */
  18915. getChildren(): Array<Bone>;
  18916. /**
  18917. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18918. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18919. * @returns a Float32Array containing matrices data
  18920. */
  18921. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18922. /**
  18923. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18924. * @returns a raw texture containing the data
  18925. */
  18926. getTransformMatrixTexture(): Nullable<RawTexture>;
  18927. /**
  18928. * Gets the current hosting scene
  18929. * @returns a scene object
  18930. */
  18931. getScene(): Scene;
  18932. /**
  18933. * Gets a string representing the current skeleton data
  18934. * @param fullDetails defines a boolean indicating if we want a verbose version
  18935. * @returns a string representing the current skeleton data
  18936. */
  18937. toString(fullDetails?: boolean): string;
  18938. /**
  18939. * Get bone's index searching by name
  18940. * @param name defines bone's name to search for
  18941. * @return the indice of the bone. Returns -1 if not found
  18942. */
  18943. getBoneIndexByName(name: string): number;
  18944. /**
  18945. * Creater a new animation range
  18946. * @param name defines the name of the range
  18947. * @param from defines the start key
  18948. * @param to defines the end key
  18949. */
  18950. createAnimationRange(name: string, from: number, to: number): void;
  18951. /**
  18952. * Delete a specific animation range
  18953. * @param name defines the name of the range
  18954. * @param deleteFrames defines if frames must be removed as well
  18955. */
  18956. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18957. /**
  18958. * Gets a specific animation range
  18959. * @param name defines the name of the range to look for
  18960. * @returns the requested animation range or null if not found
  18961. */
  18962. getAnimationRange(name: string): Nullable<AnimationRange>;
  18963. /**
  18964. * Gets the list of all animation ranges defined on this skeleton
  18965. * @returns an array
  18966. */
  18967. getAnimationRanges(): Nullable<AnimationRange>[];
  18968. /**
  18969. * Copy animation range from a source skeleton.
  18970. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18971. * @param source defines the source skeleton
  18972. * @param name defines the name of the range to copy
  18973. * @param rescaleAsRequired defines if rescaling must be applied if required
  18974. * @returns true if operation was successful
  18975. */
  18976. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18977. /**
  18978. * Forces the skeleton to go to rest pose
  18979. */
  18980. returnToRest(): void;
  18981. private _getHighestAnimationFrame;
  18982. /**
  18983. * Begin a specific animation range
  18984. * @param name defines the name of the range to start
  18985. * @param loop defines if looping must be turned on (false by default)
  18986. * @param speedRatio defines the speed ratio to apply (1 by default)
  18987. * @param onAnimationEnd defines a callback which will be called when animation will end
  18988. * @returns a new animatable
  18989. */
  18990. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18991. /** @hidden */ markAsDirty(): void;
  18992. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18993. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18994. private _computeTransformMatrices;
  18995. /**
  18996. * Build all resources required to render a skeleton
  18997. */
  18998. prepare(): void;
  18999. /**
  19000. * Gets the list of animatables currently running for this skeleton
  19001. * @returns an array of animatables
  19002. */
  19003. getAnimatables(): IAnimatable[];
  19004. /**
  19005. * Clone the current skeleton
  19006. * @param name defines the name of the new skeleton
  19007. * @param id defines the id of the new skeleton
  19008. * @returns the new skeleton
  19009. */
  19010. clone(name: string, id: string): Skeleton;
  19011. /**
  19012. * Enable animation blending for this skeleton
  19013. * @param blendingSpeed defines the blending speed to apply
  19014. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19015. */
  19016. enableBlending(blendingSpeed?: number): void;
  19017. /**
  19018. * Releases all resources associated with the current skeleton
  19019. */
  19020. dispose(): void;
  19021. /**
  19022. * Serialize the skeleton in a JSON object
  19023. * @returns a JSON object
  19024. */
  19025. serialize(): any;
  19026. /**
  19027. * Creates a new skeleton from serialized data
  19028. * @param parsedSkeleton defines the serialized data
  19029. * @param scene defines the hosting scene
  19030. * @returns a new skeleton
  19031. */
  19032. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19033. /**
  19034. * Compute all node absolute transforms
  19035. * @param forceUpdate defines if computation must be done even if cache is up to date
  19036. */
  19037. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19038. /**
  19039. * Gets the root pose matrix
  19040. * @returns a matrix
  19041. */
  19042. getPoseMatrix(): Nullable<Matrix>;
  19043. /**
  19044. * Sorts bones per internal index
  19045. */
  19046. sortBones(): void;
  19047. private _sortBones;
  19048. }
  19049. }
  19050. declare module BABYLON {
  19051. /**
  19052. * Defines a target to use with MorphTargetManager
  19053. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19054. */
  19055. export class MorphTarget implements IAnimatable {
  19056. /** defines the name of the target */
  19057. name: string;
  19058. /**
  19059. * Gets or sets the list of animations
  19060. */
  19061. animations: Animation[];
  19062. private _scene;
  19063. private _positions;
  19064. private _normals;
  19065. private _tangents;
  19066. private _influence;
  19067. /**
  19068. * Observable raised when the influence changes
  19069. */
  19070. onInfluenceChanged: Observable<boolean>;
  19071. /** @hidden */ onDataLayoutChanged: Observable<void>;
  19072. /**
  19073. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19074. */
  19075. influence: number;
  19076. /**
  19077. * Gets or sets the id of the morph Target
  19078. */
  19079. id: string;
  19080. private _animationPropertiesOverride;
  19081. /**
  19082. * Gets or sets the animation properties override
  19083. */
  19084. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19085. /**
  19086. * Creates a new MorphTarget
  19087. * @param name defines the name of the target
  19088. * @param influence defines the influence to use
  19089. * @param scene defines the scene the morphtarget belongs to
  19090. */
  19091. constructor(
  19092. /** defines the name of the target */
  19093. name: string, influence?: number, scene?: Nullable<Scene>);
  19094. /**
  19095. * Gets a boolean defining if the target contains position data
  19096. */
  19097. readonly hasPositions: boolean;
  19098. /**
  19099. * Gets a boolean defining if the target contains normal data
  19100. */
  19101. readonly hasNormals: boolean;
  19102. /**
  19103. * Gets a boolean defining if the target contains tangent data
  19104. */
  19105. readonly hasTangents: boolean;
  19106. /**
  19107. * Affects position data to this target
  19108. * @param data defines the position data to use
  19109. */
  19110. setPositions(data: Nullable<FloatArray>): void;
  19111. /**
  19112. * Gets the position data stored in this target
  19113. * @returns a FloatArray containing the position data (or null if not present)
  19114. */
  19115. getPositions(): Nullable<FloatArray>;
  19116. /**
  19117. * Affects normal data to this target
  19118. * @param data defines the normal data to use
  19119. */
  19120. setNormals(data: Nullable<FloatArray>): void;
  19121. /**
  19122. * Gets the normal data stored in this target
  19123. * @returns a FloatArray containing the normal data (or null if not present)
  19124. */
  19125. getNormals(): Nullable<FloatArray>;
  19126. /**
  19127. * Affects tangent data to this target
  19128. * @param data defines the tangent data to use
  19129. */
  19130. setTangents(data: Nullable<FloatArray>): void;
  19131. /**
  19132. * Gets the tangent data stored in this target
  19133. * @returns a FloatArray containing the tangent data (or null if not present)
  19134. */
  19135. getTangents(): Nullable<FloatArray>;
  19136. /**
  19137. * Serializes the current target into a Serialization object
  19138. * @returns the serialized object
  19139. */
  19140. serialize(): any;
  19141. /**
  19142. * Returns the string "MorphTarget"
  19143. * @returns "MorphTarget"
  19144. */
  19145. getClassName(): string;
  19146. /**
  19147. * Creates a new target from serialized data
  19148. * @param serializationObject defines the serialized data to use
  19149. * @returns a new MorphTarget
  19150. */
  19151. static Parse(serializationObject: any): MorphTarget;
  19152. /**
  19153. * Creates a MorphTarget from mesh data
  19154. * @param mesh defines the source mesh
  19155. * @param name defines the name to use for the new target
  19156. * @param influence defines the influence to attach to the target
  19157. * @returns a new MorphTarget
  19158. */
  19159. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19160. }
  19161. }
  19162. declare module BABYLON {
  19163. /**
  19164. * This class is used to deform meshes using morphing between different targets
  19165. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19166. */
  19167. export class MorphTargetManager {
  19168. private _targets;
  19169. private _targetInfluenceChangedObservers;
  19170. private _targetDataLayoutChangedObservers;
  19171. private _activeTargets;
  19172. private _scene;
  19173. private _influences;
  19174. private _supportsNormals;
  19175. private _supportsTangents;
  19176. private _vertexCount;
  19177. private _uniqueId;
  19178. private _tempInfluences;
  19179. /**
  19180. * Creates a new MorphTargetManager
  19181. * @param scene defines the current scene
  19182. */
  19183. constructor(scene?: Nullable<Scene>);
  19184. /**
  19185. * Gets the unique ID of this manager
  19186. */
  19187. readonly uniqueId: number;
  19188. /**
  19189. * Gets the number of vertices handled by this manager
  19190. */
  19191. readonly vertexCount: number;
  19192. /**
  19193. * Gets a boolean indicating if this manager supports morphing of normals
  19194. */
  19195. readonly supportsNormals: boolean;
  19196. /**
  19197. * Gets a boolean indicating if this manager supports morphing of tangents
  19198. */
  19199. readonly supportsTangents: boolean;
  19200. /**
  19201. * Gets the number of targets stored in this manager
  19202. */
  19203. readonly numTargets: number;
  19204. /**
  19205. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19206. */
  19207. readonly numInfluencers: number;
  19208. /**
  19209. * Gets the list of influences (one per target)
  19210. */
  19211. readonly influences: Float32Array;
  19212. /**
  19213. * Gets the active target at specified index. An active target is a target with an influence > 0
  19214. * @param index defines the index to check
  19215. * @returns the requested target
  19216. */
  19217. getActiveTarget(index: number): MorphTarget;
  19218. /**
  19219. * Gets the target at specified index
  19220. * @param index defines the index to check
  19221. * @returns the requested target
  19222. */
  19223. getTarget(index: number): MorphTarget;
  19224. /**
  19225. * Add a new target to this manager
  19226. * @param target defines the target to add
  19227. */
  19228. addTarget(target: MorphTarget): void;
  19229. /**
  19230. * Removes a target from the manager
  19231. * @param target defines the target to remove
  19232. */
  19233. removeTarget(target: MorphTarget): void;
  19234. /**
  19235. * Serializes the current manager into a Serialization object
  19236. * @returns the serialized object
  19237. */
  19238. serialize(): any;
  19239. private _syncActiveTargets;
  19240. /**
  19241. * Syncrhonize the targets with all the meshes using this morph target manager
  19242. */
  19243. synchronize(): void;
  19244. /**
  19245. * Creates a new MorphTargetManager from serialized data
  19246. * @param serializationObject defines the serialized data
  19247. * @param scene defines the hosting scene
  19248. * @returns the new MorphTargetManager
  19249. */
  19250. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19251. }
  19252. }
  19253. declare module BABYLON {
  19254. /**
  19255. * Class used to represent a specific level of detail of a mesh
  19256. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19257. */
  19258. export class MeshLODLevel {
  19259. /** Defines the distance where this level should star being displayed */
  19260. distance: number;
  19261. /** Defines the mesh to use to render this level */
  19262. mesh: Nullable<Mesh>;
  19263. /**
  19264. * Creates a new LOD level
  19265. * @param distance defines the distance where this level should star being displayed
  19266. * @param mesh defines the mesh to use to render this level
  19267. */
  19268. constructor(
  19269. /** Defines the distance where this level should star being displayed */
  19270. distance: number,
  19271. /** Defines the mesh to use to render this level */
  19272. mesh: Nullable<Mesh>);
  19273. }
  19274. }
  19275. declare module BABYLON {
  19276. /**
  19277. * Mesh representing the gorund
  19278. */
  19279. export class GroundMesh extends Mesh {
  19280. /** If octree should be generated */
  19281. generateOctree: boolean;
  19282. private _heightQuads;
  19283. /** @hidden */ subdivisionsX: number;
  19284. /** @hidden */ subdivisionsY: number;
  19285. /** @hidden */ width: number;
  19286. /** @hidden */ height: number;
  19287. /** @hidden */ minX: number;
  19288. /** @hidden */ maxX: number;
  19289. /** @hidden */ minZ: number;
  19290. /** @hidden */ maxZ: number;
  19291. constructor(name: string, scene: Scene);
  19292. /**
  19293. * "GroundMesh"
  19294. * @returns "GroundMesh"
  19295. */
  19296. getClassName(): string;
  19297. /**
  19298. * The minimum of x and y subdivisions
  19299. */
  19300. readonly subdivisions: number;
  19301. /**
  19302. * X subdivisions
  19303. */
  19304. readonly subdivisionsX: number;
  19305. /**
  19306. * Y subdivisions
  19307. */
  19308. readonly subdivisionsY: number;
  19309. /**
  19310. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19311. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19312. * @param chunksCount the number of subdivisions for x and y
  19313. * @param octreeBlocksSize (Default: 32)
  19314. */
  19315. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19316. /**
  19317. * Returns a height (y) value in the Worl system :
  19318. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19319. * @param x x coordinate
  19320. * @param z z coordinate
  19321. * @returns the ground y position if (x, z) are outside the ground surface.
  19322. */
  19323. getHeightAtCoordinates(x: number, z: number): number;
  19324. /**
  19325. * Returns a normalized vector (Vector3) orthogonal to the ground
  19326. * at the ground coordinates (x, z) expressed in the World system.
  19327. * @param x x coordinate
  19328. * @param z z coordinate
  19329. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19330. */
  19331. getNormalAtCoordinates(x: number, z: number): Vector3;
  19332. /**
  19333. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19334. * at the ground coordinates (x, z) expressed in the World system.
  19335. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19336. * @param x x coordinate
  19337. * @param z z coordinate
  19338. * @param ref vector to store the result
  19339. * @returns the GroundMesh.
  19340. */
  19341. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19342. /**
  19343. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19344. * if the ground has been updated.
  19345. * This can be used in the render loop.
  19346. * @returns the GroundMesh.
  19347. */
  19348. updateCoordinateHeights(): GroundMesh;
  19349. private _getFacetAt;
  19350. private _initHeightQuads;
  19351. private _computeHeightQuads;
  19352. /**
  19353. * Serializes this ground mesh
  19354. * @param serializationObject object to write serialization to
  19355. */
  19356. serialize(serializationObject: any): void;
  19357. /**
  19358. * Parses a serialized ground mesh
  19359. * @param parsedMesh the serialized mesh
  19360. * @param scene the scene to create the ground mesh in
  19361. * @returns the created ground mesh
  19362. */
  19363. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19364. }
  19365. }
  19366. declare module BABYLON {
  19367. /**
  19368. * Interface for Physics-Joint data
  19369. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19370. */
  19371. export interface PhysicsJointData {
  19372. /**
  19373. * The main pivot of the joint
  19374. */
  19375. mainPivot?: Vector3;
  19376. /**
  19377. * The connected pivot of the joint
  19378. */
  19379. connectedPivot?: Vector3;
  19380. /**
  19381. * The main axis of the joint
  19382. */
  19383. mainAxis?: Vector3;
  19384. /**
  19385. * The connected axis of the joint
  19386. */
  19387. connectedAxis?: Vector3;
  19388. /**
  19389. * The collision of the joint
  19390. */
  19391. collision?: boolean;
  19392. /**
  19393. * Native Oimo/Cannon/Energy data
  19394. */
  19395. nativeParams?: any;
  19396. }
  19397. /**
  19398. * This is a holder class for the physics joint created by the physics plugin
  19399. * It holds a set of functions to control the underlying joint
  19400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19401. */
  19402. export class PhysicsJoint {
  19403. /**
  19404. * The type of the physics joint
  19405. */
  19406. type: number;
  19407. /**
  19408. * The data for the physics joint
  19409. */
  19410. jointData: PhysicsJointData;
  19411. private _physicsJoint;
  19412. protected _physicsPlugin: IPhysicsEnginePlugin;
  19413. /**
  19414. * Initializes the physics joint
  19415. * @param type The type of the physics joint
  19416. * @param jointData The data for the physics joint
  19417. */
  19418. constructor(
  19419. /**
  19420. * The type of the physics joint
  19421. */
  19422. type: number,
  19423. /**
  19424. * The data for the physics joint
  19425. */
  19426. jointData: PhysicsJointData);
  19427. /**
  19428. * Gets the physics joint
  19429. */
  19430. /**
  19431. * Sets the physics joint
  19432. */
  19433. physicsJoint: any;
  19434. /**
  19435. * Sets the physics plugin
  19436. */
  19437. physicsPlugin: IPhysicsEnginePlugin;
  19438. /**
  19439. * Execute a function that is physics-plugin specific.
  19440. * @param {Function} func the function that will be executed.
  19441. * It accepts two parameters: the physics world and the physics joint
  19442. */
  19443. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19444. /**
  19445. * Distance-Joint type
  19446. */
  19447. static DistanceJoint: number;
  19448. /**
  19449. * Hinge-Joint type
  19450. */
  19451. static HingeJoint: number;
  19452. /**
  19453. * Ball-and-Socket joint type
  19454. */
  19455. static BallAndSocketJoint: number;
  19456. /**
  19457. * Wheel-Joint type
  19458. */
  19459. static WheelJoint: number;
  19460. /**
  19461. * Slider-Joint type
  19462. */
  19463. static SliderJoint: number;
  19464. /**
  19465. * Prismatic-Joint type
  19466. */
  19467. static PrismaticJoint: number;
  19468. /**
  19469. * Universal-Joint type
  19470. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19471. */
  19472. static UniversalJoint: number;
  19473. /**
  19474. * Hinge-Joint 2 type
  19475. */
  19476. static Hinge2Joint: number;
  19477. /**
  19478. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19479. */
  19480. static PointToPointJoint: number;
  19481. /**
  19482. * Spring-Joint type
  19483. */
  19484. static SpringJoint: number;
  19485. /**
  19486. * Lock-Joint type
  19487. */
  19488. static LockJoint: number;
  19489. }
  19490. /**
  19491. * A class representing a physics distance joint
  19492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19493. */
  19494. export class DistanceJoint extends PhysicsJoint {
  19495. /**
  19496. *
  19497. * @param jointData The data for the Distance-Joint
  19498. */
  19499. constructor(jointData: DistanceJointData);
  19500. /**
  19501. * Update the predefined distance.
  19502. * @param maxDistance The maximum preferred distance
  19503. * @param minDistance The minimum preferred distance
  19504. */
  19505. updateDistance(maxDistance: number, minDistance?: number): void;
  19506. }
  19507. /**
  19508. * Represents a Motor-Enabled Joint
  19509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19510. */
  19511. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19512. /**
  19513. * Initializes the Motor-Enabled Joint
  19514. * @param type The type of the joint
  19515. * @param jointData The physica joint data for the joint
  19516. */
  19517. constructor(type: number, jointData: PhysicsJointData);
  19518. /**
  19519. * Set the motor values.
  19520. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19521. * @param force the force to apply
  19522. * @param maxForce max force for this motor.
  19523. */
  19524. setMotor(force?: number, maxForce?: number): void;
  19525. /**
  19526. * Set the motor's limits.
  19527. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19528. * @param upperLimit The upper limit of the motor
  19529. * @param lowerLimit The lower limit of the motor
  19530. */
  19531. setLimit(upperLimit: number, lowerLimit?: number): void;
  19532. }
  19533. /**
  19534. * This class represents a single physics Hinge-Joint
  19535. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19536. */
  19537. export class HingeJoint extends MotorEnabledJoint {
  19538. /**
  19539. * Initializes the Hinge-Joint
  19540. * @param jointData The joint data for the Hinge-Joint
  19541. */
  19542. constructor(jointData: PhysicsJointData);
  19543. /**
  19544. * Set the motor values.
  19545. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19546. * @param {number} force the force to apply
  19547. * @param {number} maxForce max force for this motor.
  19548. */
  19549. setMotor(force?: number, maxForce?: number): void;
  19550. /**
  19551. * Set the motor's limits.
  19552. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19553. * @param upperLimit The upper limit of the motor
  19554. * @param lowerLimit The lower limit of the motor
  19555. */
  19556. setLimit(upperLimit: number, lowerLimit?: number): void;
  19557. }
  19558. /**
  19559. * This class represents a dual hinge physics joint (same as wheel joint)
  19560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19561. */
  19562. export class Hinge2Joint extends MotorEnabledJoint {
  19563. /**
  19564. * Initializes the Hinge2-Joint
  19565. * @param jointData The joint data for the Hinge2-Joint
  19566. */
  19567. constructor(jointData: PhysicsJointData);
  19568. /**
  19569. * Set the motor values.
  19570. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19571. * @param {number} targetSpeed the speed the motor is to reach
  19572. * @param {number} maxForce max force for this motor.
  19573. * @param {motorIndex} the motor's index, 0 or 1.
  19574. */
  19575. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19576. /**
  19577. * Set the motor limits.
  19578. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19579. * @param {number} upperLimit the upper limit
  19580. * @param {number} lowerLimit lower limit
  19581. * @param {motorIndex} the motor's index, 0 or 1.
  19582. */
  19583. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19584. }
  19585. /**
  19586. * Interface for a motor enabled joint
  19587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19588. */
  19589. export interface IMotorEnabledJoint {
  19590. /**
  19591. * Physics joint
  19592. */
  19593. physicsJoint: any;
  19594. /**
  19595. * Sets the motor of the motor-enabled joint
  19596. * @param force The force of the motor
  19597. * @param maxForce The maximum force of the motor
  19598. * @param motorIndex The index of the motor
  19599. */
  19600. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19601. /**
  19602. * Sets the limit of the motor
  19603. * @param upperLimit The upper limit of the motor
  19604. * @param lowerLimit The lower limit of the motor
  19605. * @param motorIndex The index of the motor
  19606. */
  19607. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19608. }
  19609. /**
  19610. * Joint data for a Distance-Joint
  19611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19612. */
  19613. export interface DistanceJointData extends PhysicsJointData {
  19614. /**
  19615. * Max distance the 2 joint objects can be apart
  19616. */
  19617. maxDistance: number;
  19618. }
  19619. /**
  19620. * Joint data from a spring joint
  19621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19622. */
  19623. export interface SpringJointData extends PhysicsJointData {
  19624. /**
  19625. * Length of the spring
  19626. */
  19627. length: number;
  19628. /**
  19629. * Stiffness of the spring
  19630. */
  19631. stiffness: number;
  19632. /**
  19633. * Damping of the spring
  19634. */
  19635. damping: number;
  19636. /** this callback will be called when applying the force to the impostors. */
  19637. forceApplicationCallback: () => void;
  19638. }
  19639. }
  19640. declare module BABYLON {
  19641. /**
  19642. * Holds the data for the raycast result
  19643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19644. */
  19645. export class PhysicsRaycastResult {
  19646. private _hasHit;
  19647. private _hitDistance;
  19648. private _hitNormalWorld;
  19649. private _hitPointWorld;
  19650. private _rayFromWorld;
  19651. private _rayToWorld;
  19652. /**
  19653. * Gets if there was a hit
  19654. */
  19655. readonly hasHit: boolean;
  19656. /**
  19657. * Gets the distance from the hit
  19658. */
  19659. readonly hitDistance: number;
  19660. /**
  19661. * Gets the hit normal/direction in the world
  19662. */
  19663. readonly hitNormalWorld: Vector3;
  19664. /**
  19665. * Gets the hit point in the world
  19666. */
  19667. readonly hitPointWorld: Vector3;
  19668. /**
  19669. * Gets the ray "start point" of the ray in the world
  19670. */
  19671. readonly rayFromWorld: Vector3;
  19672. /**
  19673. * Gets the ray "end point" of the ray in the world
  19674. */
  19675. readonly rayToWorld: Vector3;
  19676. /**
  19677. * Sets the hit data (normal & point in world space)
  19678. * @param hitNormalWorld defines the normal in world space
  19679. * @param hitPointWorld defines the point in world space
  19680. */
  19681. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19682. /**
  19683. * Sets the distance from the start point to the hit point
  19684. * @param distance
  19685. */
  19686. setHitDistance(distance: number): void;
  19687. /**
  19688. * Calculates the distance manually
  19689. */
  19690. calculateHitDistance(): void;
  19691. /**
  19692. * Resets all the values to default
  19693. * @param from The from point on world space
  19694. * @param to The to point on world space
  19695. */
  19696. reset(from?: Vector3, to?: Vector3): void;
  19697. }
  19698. /**
  19699. * Interface for the size containing width and height
  19700. */
  19701. interface IXYZ {
  19702. /**
  19703. * X
  19704. */
  19705. x: number;
  19706. /**
  19707. * Y
  19708. */
  19709. y: number;
  19710. /**
  19711. * Z
  19712. */
  19713. z: number;
  19714. }
  19715. }
  19716. declare module BABYLON {
  19717. /**
  19718. * Interface used to describe a physics joint
  19719. */
  19720. export interface PhysicsImpostorJoint {
  19721. /** Defines the main impostor to which the joint is linked */
  19722. mainImpostor: PhysicsImpostor;
  19723. /** Defines the impostor that is connected to the main impostor using this joint */
  19724. connectedImpostor: PhysicsImpostor;
  19725. /** Defines the joint itself */
  19726. joint: PhysicsJoint;
  19727. }
  19728. /** @hidden */
  19729. export interface IPhysicsEnginePlugin {
  19730. world: any;
  19731. name: string;
  19732. setGravity(gravity: Vector3): void;
  19733. setTimeStep(timeStep: number): void;
  19734. getTimeStep(): number;
  19735. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19736. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19737. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19738. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19739. removePhysicsBody(impostor: PhysicsImpostor): void;
  19740. generateJoint(joint: PhysicsImpostorJoint): void;
  19741. removeJoint(joint: PhysicsImpostorJoint): void;
  19742. isSupported(): boolean;
  19743. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19744. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19745. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19746. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19747. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19748. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19749. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19750. getBodyMass(impostor: PhysicsImpostor): number;
  19751. getBodyFriction(impostor: PhysicsImpostor): number;
  19752. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19753. getBodyRestitution(impostor: PhysicsImpostor): number;
  19754. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19755. getBodyPressure?(impostor: PhysicsImpostor): number;
  19756. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19757. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19758. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19759. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19760. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19761. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19762. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19763. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19764. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19765. sleepBody(impostor: PhysicsImpostor): void;
  19766. wakeUpBody(impostor: PhysicsImpostor): void;
  19767. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19768. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19769. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19770. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19771. getRadius(impostor: PhysicsImpostor): number;
  19772. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19773. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19774. dispose(): void;
  19775. }
  19776. /**
  19777. * Interface used to define a physics engine
  19778. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19779. */
  19780. export interface IPhysicsEngine {
  19781. /**
  19782. * Gets the gravity vector used by the simulation
  19783. */
  19784. gravity: Vector3;
  19785. /**
  19786. * Sets the gravity vector used by the simulation
  19787. * @param gravity defines the gravity vector to use
  19788. */
  19789. setGravity(gravity: Vector3): void;
  19790. /**
  19791. * Set the time step of the physics engine.
  19792. * Default is 1/60.
  19793. * To slow it down, enter 1/600 for example.
  19794. * To speed it up, 1/30
  19795. * @param newTimeStep the new timestep to apply to this world.
  19796. */
  19797. setTimeStep(newTimeStep: number): void;
  19798. /**
  19799. * Get the time step of the physics engine.
  19800. * @returns the current time step
  19801. */
  19802. getTimeStep(): number;
  19803. /**
  19804. * Release all resources
  19805. */
  19806. dispose(): void;
  19807. /**
  19808. * Gets the name of the current physics plugin
  19809. * @returns the name of the plugin
  19810. */
  19811. getPhysicsPluginName(): string;
  19812. /**
  19813. * Adding a new impostor for the impostor tracking.
  19814. * This will be done by the impostor itself.
  19815. * @param impostor the impostor to add
  19816. */
  19817. addImpostor(impostor: PhysicsImpostor): void;
  19818. /**
  19819. * Remove an impostor from the engine.
  19820. * This impostor and its mesh will not longer be updated by the physics engine.
  19821. * @param impostor the impostor to remove
  19822. */
  19823. removeImpostor(impostor: PhysicsImpostor): void;
  19824. /**
  19825. * Add a joint to the physics engine
  19826. * @param mainImpostor defines the main impostor to which the joint is added.
  19827. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19828. * @param joint defines the joint that will connect both impostors.
  19829. */
  19830. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19831. /**
  19832. * Removes a joint from the simulation
  19833. * @param mainImpostor defines the impostor used with the joint
  19834. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19835. * @param joint defines the joint to remove
  19836. */
  19837. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19838. /**
  19839. * Gets the current plugin used to run the simulation
  19840. * @returns current plugin
  19841. */
  19842. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19843. /**
  19844. * Gets the list of physic impostors
  19845. * @returns an array of PhysicsImpostor
  19846. */
  19847. getImpostors(): Array<PhysicsImpostor>;
  19848. /**
  19849. * Gets the impostor for a physics enabled object
  19850. * @param object defines the object impersonated by the impostor
  19851. * @returns the PhysicsImpostor or null if not found
  19852. */
  19853. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19854. /**
  19855. * Gets the impostor for a physics body object
  19856. * @param body defines physics body used by the impostor
  19857. * @returns the PhysicsImpostor or null if not found
  19858. */
  19859. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19860. /**
  19861. * Does a raycast in the physics world
  19862. * @param from when should the ray start?
  19863. * @param to when should the ray end?
  19864. * @returns PhysicsRaycastResult
  19865. */
  19866. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19867. /**
  19868. * Called by the scene. No need to call it.
  19869. * @param delta defines the timespam between frames
  19870. */ step(delta: number): void;
  19871. }
  19872. }
  19873. declare module BABYLON {
  19874. /**
  19875. * The interface for the physics imposter parameters
  19876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19877. */
  19878. export interface PhysicsImpostorParameters {
  19879. /**
  19880. * The mass of the physics imposter
  19881. */
  19882. mass: number;
  19883. /**
  19884. * The friction of the physics imposter
  19885. */
  19886. friction?: number;
  19887. /**
  19888. * The coefficient of restitution of the physics imposter
  19889. */
  19890. restitution?: number;
  19891. /**
  19892. * The native options of the physics imposter
  19893. */
  19894. nativeOptions?: any;
  19895. /**
  19896. * Specifies if the parent should be ignored
  19897. */
  19898. ignoreParent?: boolean;
  19899. /**
  19900. * Specifies if bi-directional transformations should be disabled
  19901. */
  19902. disableBidirectionalTransformation?: boolean;
  19903. /**
  19904. * The pressure inside the physics imposter, soft object only
  19905. */
  19906. pressure?: number;
  19907. /**
  19908. * The stiffness the physics imposter, soft object only
  19909. */
  19910. stiffness?: number;
  19911. /**
  19912. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19913. */
  19914. velocityIterations?: number;
  19915. /**
  19916. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19917. */
  19918. positionIterations?: number;
  19919. /**
  19920. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19921. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19922. * Add to fix multiple points
  19923. */
  19924. fixedPoints?: number;
  19925. /**
  19926. * The collision margin around a soft object
  19927. */
  19928. margin?: number;
  19929. /**
  19930. * The collision margin around a soft object
  19931. */
  19932. damping?: number;
  19933. /**
  19934. * The path for a rope based on an extrusion
  19935. */
  19936. path?: any;
  19937. /**
  19938. * The shape of an extrusion used for a rope based on an extrusion
  19939. */
  19940. shape?: any;
  19941. }
  19942. /**
  19943. * Interface for a physics-enabled object
  19944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19945. */
  19946. export interface IPhysicsEnabledObject {
  19947. /**
  19948. * The position of the physics-enabled object
  19949. */
  19950. position: Vector3;
  19951. /**
  19952. * The rotation of the physics-enabled object
  19953. */
  19954. rotationQuaternion: Nullable<Quaternion>;
  19955. /**
  19956. * The scale of the physics-enabled object
  19957. */
  19958. scaling: Vector3;
  19959. /**
  19960. * The rotation of the physics-enabled object
  19961. */
  19962. rotation?: Vector3;
  19963. /**
  19964. * The parent of the physics-enabled object
  19965. */
  19966. parent?: any;
  19967. /**
  19968. * The bounding info of the physics-enabled object
  19969. * @returns The bounding info of the physics-enabled object
  19970. */
  19971. getBoundingInfo(): BoundingInfo;
  19972. /**
  19973. * Computes the world matrix
  19974. * @param force Specifies if the world matrix should be computed by force
  19975. * @returns A world matrix
  19976. */
  19977. computeWorldMatrix(force: boolean): Matrix;
  19978. /**
  19979. * Gets the world matrix
  19980. * @returns A world matrix
  19981. */
  19982. getWorldMatrix?(): Matrix;
  19983. /**
  19984. * Gets the child meshes
  19985. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19986. * @returns An array of abstract meshes
  19987. */
  19988. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19989. /**
  19990. * Gets the vertex data
  19991. * @param kind The type of vertex data
  19992. * @returns A nullable array of numbers, or a float32 array
  19993. */
  19994. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19995. /**
  19996. * Gets the indices from the mesh
  19997. * @returns A nullable array of index arrays
  19998. */
  19999. getIndices?(): Nullable<IndicesArray>;
  20000. /**
  20001. * Gets the scene from the mesh
  20002. * @returns the indices array or null
  20003. */
  20004. getScene?(): Scene;
  20005. /**
  20006. * Gets the absolute position from the mesh
  20007. * @returns the absolute position
  20008. */
  20009. getAbsolutePosition(): Vector3;
  20010. /**
  20011. * Gets the absolute pivot point from the mesh
  20012. * @returns the absolute pivot point
  20013. */
  20014. getAbsolutePivotPoint(): Vector3;
  20015. /**
  20016. * Rotates the mesh
  20017. * @param axis The axis of rotation
  20018. * @param amount The amount of rotation
  20019. * @param space The space of the rotation
  20020. * @returns The rotation transform node
  20021. */
  20022. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20023. /**
  20024. * Translates the mesh
  20025. * @param axis The axis of translation
  20026. * @param distance The distance of translation
  20027. * @param space The space of the translation
  20028. * @returns The transform node
  20029. */
  20030. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20031. /**
  20032. * Sets the absolute position of the mesh
  20033. * @param absolutePosition The absolute position of the mesh
  20034. * @returns The transform node
  20035. */
  20036. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20037. /**
  20038. * Gets the class name of the mesh
  20039. * @returns The class name
  20040. */
  20041. getClassName(): string;
  20042. }
  20043. /**
  20044. * Represents a physics imposter
  20045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20046. */
  20047. export class PhysicsImpostor {
  20048. /**
  20049. * The physics-enabled object used as the physics imposter
  20050. */
  20051. object: IPhysicsEnabledObject;
  20052. /**
  20053. * The type of the physics imposter
  20054. */
  20055. type: number;
  20056. private _options;
  20057. private _scene?;
  20058. /**
  20059. * The default object size of the imposter
  20060. */
  20061. static DEFAULT_OBJECT_SIZE: Vector3;
  20062. /**
  20063. * The identity quaternion of the imposter
  20064. */
  20065. static IDENTITY_QUATERNION: Quaternion;
  20066. /** @hidden */ pluginData: any;
  20067. private _physicsEngine;
  20068. private _physicsBody;
  20069. private _bodyUpdateRequired;
  20070. private _onBeforePhysicsStepCallbacks;
  20071. private _onAfterPhysicsStepCallbacks;
  20072. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  20073. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20074. otherImpostors: Array<PhysicsImpostor>;
  20075. }>;
  20076. private _deltaPosition;
  20077. private _deltaRotation;
  20078. private _deltaRotationConjugated;
  20079. /** hidden */ isFromLine: boolean;
  20080. private _parent;
  20081. private _isDisposed;
  20082. private static _tmpVecs;
  20083. private static _tmpQuat;
  20084. /**
  20085. * Specifies if the physics imposter is disposed
  20086. */
  20087. readonly isDisposed: boolean;
  20088. /**
  20089. * Gets the mass of the physics imposter
  20090. */
  20091. mass: number;
  20092. /**
  20093. * Gets the coefficient of friction
  20094. */
  20095. /**
  20096. * Sets the coefficient of friction
  20097. */
  20098. friction: number;
  20099. /**
  20100. * Gets the coefficient of restitution
  20101. */
  20102. /**
  20103. * Sets the coefficient of restitution
  20104. */
  20105. restitution: number;
  20106. /**
  20107. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20108. */
  20109. /**
  20110. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20111. */
  20112. pressure: number;
  20113. /**
  20114. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20115. */
  20116. /**
  20117. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20118. */
  20119. stiffness: number;
  20120. /**
  20121. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20122. */
  20123. /**
  20124. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20125. */
  20126. velocityIterations: number;
  20127. /**
  20128. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20129. */
  20130. /**
  20131. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20132. */
  20133. positionIterations: number;
  20134. /**
  20135. * The unique id of the physics imposter
  20136. * set by the physics engine when adding this impostor to the array
  20137. */
  20138. uniqueId: number;
  20139. /**
  20140. * @hidden
  20141. */
  20142. soft: boolean;
  20143. /**
  20144. * @hidden
  20145. */
  20146. segments: number;
  20147. private _joints;
  20148. /**
  20149. * Initializes the physics imposter
  20150. * @param object The physics-enabled object used as the physics imposter
  20151. * @param type The type of the physics imposter
  20152. * @param _options The options for the physics imposter
  20153. * @param _scene The Babylon scene
  20154. */
  20155. constructor(
  20156. /**
  20157. * The physics-enabled object used as the physics imposter
  20158. */
  20159. object: IPhysicsEnabledObject,
  20160. /**
  20161. * The type of the physics imposter
  20162. */
  20163. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20164. /**
  20165. * This function will completly initialize this impostor.
  20166. * It will create a new body - but only if this mesh has no parent.
  20167. * If it has, this impostor will not be used other than to define the impostor
  20168. * of the child mesh.
  20169. * @hidden
  20170. */ init(): void;
  20171. private _getPhysicsParent;
  20172. /**
  20173. * Should a new body be generated.
  20174. * @returns boolean specifying if body initialization is required
  20175. */
  20176. isBodyInitRequired(): boolean;
  20177. /**
  20178. * Sets the updated scaling
  20179. * @param updated Specifies if the scaling is updated
  20180. */
  20181. setScalingUpdated(): void;
  20182. /**
  20183. * Force a regeneration of this or the parent's impostor's body.
  20184. * Use under cautious - This will remove all joints already implemented.
  20185. */
  20186. forceUpdate(): void;
  20187. /**
  20188. * Gets the body that holds this impostor. Either its own, or its parent.
  20189. */
  20190. /**
  20191. * Set the physics body. Used mainly by the physics engine/plugin
  20192. */
  20193. physicsBody: any;
  20194. /**
  20195. * Get the parent of the physics imposter
  20196. * @returns Physics imposter or null
  20197. */
  20198. /**
  20199. * Sets the parent of the physics imposter
  20200. */
  20201. parent: Nullable<PhysicsImpostor>;
  20202. /**
  20203. * Resets the update flags
  20204. */
  20205. resetUpdateFlags(): void;
  20206. /**
  20207. * Gets the object extend size
  20208. * @returns the object extend size
  20209. */
  20210. getObjectExtendSize(): Vector3;
  20211. /**
  20212. * Gets the object center
  20213. * @returns The object center
  20214. */
  20215. getObjectCenter(): Vector3;
  20216. /**
  20217. * Get a specific parametes from the options parameter
  20218. * @param paramName The object parameter name
  20219. * @returns The object parameter
  20220. */
  20221. getParam(paramName: string): any;
  20222. /**
  20223. * Sets a specific parameter in the options given to the physics plugin
  20224. * @param paramName The parameter name
  20225. * @param value The value of the parameter
  20226. */
  20227. setParam(paramName: string, value: number): void;
  20228. /**
  20229. * Specifically change the body's mass option. Won't recreate the physics body object
  20230. * @param mass The mass of the physics imposter
  20231. */
  20232. setMass(mass: number): void;
  20233. /**
  20234. * Gets the linear velocity
  20235. * @returns linear velocity or null
  20236. */
  20237. getLinearVelocity(): Nullable<Vector3>;
  20238. /**
  20239. * Sets the linear velocity
  20240. * @param velocity linear velocity or null
  20241. */
  20242. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20243. /**
  20244. * Gets the angular velocity
  20245. * @returns angular velocity or null
  20246. */
  20247. getAngularVelocity(): Nullable<Vector3>;
  20248. /**
  20249. * Sets the angular velocity
  20250. * @param velocity The velocity or null
  20251. */
  20252. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20253. /**
  20254. * Execute a function with the physics plugin native code
  20255. * Provide a function the will have two variables - the world object and the physics body object
  20256. * @param func The function to execute with the physics plugin native code
  20257. */
  20258. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20259. /**
  20260. * Register a function that will be executed before the physics world is stepping forward
  20261. * @param func The function to execute before the physics world is stepped forward
  20262. */
  20263. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20264. /**
  20265. * Unregister a function that will be executed before the physics world is stepping forward
  20266. * @param func The function to execute before the physics world is stepped forward
  20267. */
  20268. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20269. /**
  20270. * Register a function that will be executed after the physics step
  20271. * @param func The function to execute after physics step
  20272. */
  20273. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20274. /**
  20275. * Unregisters a function that will be executed after the physics step
  20276. * @param func The function to execute after physics step
  20277. */
  20278. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20279. /**
  20280. * register a function that will be executed when this impostor collides against a different body
  20281. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20282. * @param func Callback that is executed on collision
  20283. */
  20284. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20285. /**
  20286. * Unregisters the physics imposter on contact
  20287. * @param collideAgainst The physics object to collide against
  20288. * @param func Callback to execute on collision
  20289. */
  20290. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20291. private _tmpQuat;
  20292. private _tmpQuat2;
  20293. /**
  20294. * Get the parent rotation
  20295. * @returns The parent rotation
  20296. */
  20297. getParentsRotation(): Quaternion;
  20298. /**
  20299. * this function is executed by the physics engine.
  20300. */
  20301. beforeStep: () => void;
  20302. /**
  20303. * this function is executed by the physics engine
  20304. */
  20305. afterStep: () => void;
  20306. /**
  20307. * Legacy collision detection event support
  20308. */
  20309. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20310. /**
  20311. * event and body object due to cannon's event-based architecture.
  20312. */
  20313. onCollide: (e: {
  20314. body: any;
  20315. }) => void;
  20316. /**
  20317. * Apply a force
  20318. * @param force The force to apply
  20319. * @param contactPoint The contact point for the force
  20320. * @returns The physics imposter
  20321. */
  20322. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20323. /**
  20324. * Apply an impulse
  20325. * @param force The impulse force
  20326. * @param contactPoint The contact point for the impulse force
  20327. * @returns The physics imposter
  20328. */
  20329. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20330. /**
  20331. * A help function to create a joint
  20332. * @param otherImpostor A physics imposter used to create a joint
  20333. * @param jointType The type of joint
  20334. * @param jointData The data for the joint
  20335. * @returns The physics imposter
  20336. */
  20337. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20338. /**
  20339. * Add a joint to this impostor with a different impostor
  20340. * @param otherImpostor A physics imposter used to add a joint
  20341. * @param joint The joint to add
  20342. * @returns The physics imposter
  20343. */
  20344. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20345. /**
  20346. * Add an anchor to a cloth impostor
  20347. * @param otherImpostor rigid impostor to anchor to
  20348. * @param width ratio across width from 0 to 1
  20349. * @param height ratio up height from 0 to 1
  20350. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20351. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20352. * @returns impostor the soft imposter
  20353. */
  20354. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20355. /**
  20356. * Add a hook to a rope impostor
  20357. * @param otherImpostor rigid impostor to anchor to
  20358. * @param length ratio across rope from 0 to 1
  20359. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20360. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20361. * @returns impostor the rope imposter
  20362. */
  20363. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20364. /**
  20365. * Will keep this body still, in a sleep mode.
  20366. * @returns the physics imposter
  20367. */
  20368. sleep(): PhysicsImpostor;
  20369. /**
  20370. * Wake the body up.
  20371. * @returns The physics imposter
  20372. */
  20373. wakeUp(): PhysicsImpostor;
  20374. /**
  20375. * Clones the physics imposter
  20376. * @param newObject The physics imposter clones to this physics-enabled object
  20377. * @returns A nullable physics imposter
  20378. */
  20379. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20380. /**
  20381. * Disposes the physics imposter
  20382. */
  20383. dispose(): void;
  20384. /**
  20385. * Sets the delta position
  20386. * @param position The delta position amount
  20387. */
  20388. setDeltaPosition(position: Vector3): void;
  20389. /**
  20390. * Sets the delta rotation
  20391. * @param rotation The delta rotation amount
  20392. */
  20393. setDeltaRotation(rotation: Quaternion): void;
  20394. /**
  20395. * Gets the box size of the physics imposter and stores the result in the input parameter
  20396. * @param result Stores the box size
  20397. * @returns The physics imposter
  20398. */
  20399. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20400. /**
  20401. * Gets the radius of the physics imposter
  20402. * @returns Radius of the physics imposter
  20403. */
  20404. getRadius(): number;
  20405. /**
  20406. * Sync a bone with this impostor
  20407. * @param bone The bone to sync to the impostor.
  20408. * @param boneMesh The mesh that the bone is influencing.
  20409. * @param jointPivot The pivot of the joint / bone in local space.
  20410. * @param distToJoint Optional distance from the impostor to the joint.
  20411. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20412. */
  20413. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20414. /**
  20415. * Sync impostor to a bone
  20416. * @param bone The bone that the impostor will be synced to.
  20417. * @param boneMesh The mesh that the bone is influencing.
  20418. * @param jointPivot The pivot of the joint / bone in local space.
  20419. * @param distToJoint Optional distance from the impostor to the joint.
  20420. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20421. * @param boneAxis Optional vector3 axis the bone is aligned with
  20422. */
  20423. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20424. /**
  20425. * No-Imposter type
  20426. */
  20427. static NoImpostor: number;
  20428. /**
  20429. * Sphere-Imposter type
  20430. */
  20431. static SphereImpostor: number;
  20432. /**
  20433. * Box-Imposter type
  20434. */
  20435. static BoxImpostor: number;
  20436. /**
  20437. * Plane-Imposter type
  20438. */
  20439. static PlaneImpostor: number;
  20440. /**
  20441. * Mesh-imposter type
  20442. */
  20443. static MeshImpostor: number;
  20444. /**
  20445. * Cylinder-Imposter type
  20446. */
  20447. static CylinderImpostor: number;
  20448. /**
  20449. * Particle-Imposter type
  20450. */
  20451. static ParticleImpostor: number;
  20452. /**
  20453. * Heightmap-Imposter type
  20454. */
  20455. static HeightmapImpostor: number;
  20456. /**
  20457. * ConvexHull-Impostor type (Ammo.js plugin only)
  20458. */
  20459. static ConvexHullImpostor: number;
  20460. /**
  20461. * Rope-Imposter type
  20462. */
  20463. static RopeImpostor: number;
  20464. /**
  20465. * Cloth-Imposter type
  20466. */
  20467. static ClothImpostor: number;
  20468. /**
  20469. * Softbody-Imposter type
  20470. */
  20471. static SoftbodyImpostor: number;
  20472. }
  20473. }
  20474. declare module BABYLON {
  20475. /**
  20476. * @hidden
  20477. **/
  20478. export class _CreationDataStorage {
  20479. closePath?: boolean;
  20480. closeArray?: boolean;
  20481. idx: number[];
  20482. dashSize: number;
  20483. gapSize: number;
  20484. path3D: Path3D;
  20485. pathArray: Vector3[][];
  20486. arc: number;
  20487. radius: number;
  20488. cap: number;
  20489. tessellation: number;
  20490. }
  20491. /**
  20492. * @hidden
  20493. **/ private class _InstanceDataStorage {
  20494. visibleInstances: any;
  20495. batchCache: _InstancesBatch;
  20496. instancesBufferSize: number;
  20497. instancesBuffer: Nullable<Buffer>;
  20498. instancesData: Float32Array;
  20499. overridenInstanceCount: number;
  20500. isFrozen: boolean;
  20501. previousBatch: _InstancesBatch;
  20502. hardwareInstancedRendering: boolean;
  20503. sideOrientation: number;
  20504. }
  20505. /**
  20506. * @hidden
  20507. **/
  20508. export class _InstancesBatch {
  20509. mustReturn: boolean;
  20510. visibleInstances: Nullable<InstancedMesh[]>[];
  20511. renderSelf: boolean[];
  20512. hardwareInstancedRendering: boolean[];
  20513. }
  20514. /**
  20515. * Class used to represent renderable models
  20516. */
  20517. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20518. /**
  20519. * Mesh side orientation : usually the external or front surface
  20520. */
  20521. static readonly FRONTSIDE: number;
  20522. /**
  20523. * Mesh side orientation : usually the internal or back surface
  20524. */
  20525. static readonly BACKSIDE: number;
  20526. /**
  20527. * Mesh side orientation : both internal and external or front and back surfaces
  20528. */
  20529. static readonly DOUBLESIDE: number;
  20530. /**
  20531. * Mesh side orientation : by default, `FRONTSIDE`
  20532. */
  20533. static readonly DEFAULTSIDE: number;
  20534. /**
  20535. * Mesh cap setting : no cap
  20536. */
  20537. static readonly NO_CAP: number;
  20538. /**
  20539. * Mesh cap setting : one cap at the beginning of the mesh
  20540. */
  20541. static readonly CAP_START: number;
  20542. /**
  20543. * Mesh cap setting : one cap at the end of the mesh
  20544. */
  20545. static readonly CAP_END: number;
  20546. /**
  20547. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20548. */
  20549. static readonly CAP_ALL: number;
  20550. /**
  20551. * Gets the default side orientation.
  20552. * @param orientation the orientation to value to attempt to get
  20553. * @returns the default orientation
  20554. * @hidden
  20555. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  20556. private _onBeforeRenderObservable;
  20557. private _onBeforeBindObservable;
  20558. private _onAfterRenderObservable;
  20559. private _onBeforeDrawObservable;
  20560. /**
  20561. * An event triggered before rendering the mesh
  20562. */
  20563. readonly onBeforeRenderObservable: Observable<Mesh>;
  20564. /**
  20565. * An event triggered before binding the mesh
  20566. */
  20567. readonly onBeforeBindObservable: Observable<Mesh>;
  20568. /**
  20569. * An event triggered after rendering the mesh
  20570. */
  20571. readonly onAfterRenderObservable: Observable<Mesh>;
  20572. /**
  20573. * An event triggered before drawing the mesh
  20574. */
  20575. readonly onBeforeDrawObservable: Observable<Mesh>;
  20576. private _onBeforeDrawObserver;
  20577. /**
  20578. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20579. */
  20580. onBeforeDraw: () => void;
  20581. /**
  20582. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20583. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20584. */
  20585. delayLoadState: number;
  20586. /**
  20587. * Gets the list of instances created from this mesh
  20588. * it is not supposed to be modified manually.
  20589. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20590. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20591. */
  20592. instances: InstancedMesh[];
  20593. /**
  20594. * Gets the file containing delay loading data for this mesh
  20595. */
  20596. delayLoadingFile: string;
  20597. /** @hidden */ binaryInfo: any;
  20598. private _LODLevels;
  20599. /**
  20600. * User defined function used to change how LOD level selection is done
  20601. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20602. */
  20603. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20604. private _morphTargetManager;
  20605. /**
  20606. * Gets or sets the morph target manager
  20607. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20608. */
  20609. morphTargetManager: Nullable<MorphTargetManager>;
  20610. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  20611. /** @hidden */ geometry: Nullable<Geometry>;
  20612. /** @hidden */ delayInfo: Array<string>;
  20613. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20614. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  20615. private _effectiveMaterial;
  20616. /** @hidden */ shouldGenerateFlatShading: boolean;
  20617. private _preActivateId;
  20618. /** @hidden */ originalBuilderSideOrientation: number;
  20619. /**
  20620. * Use this property to change the original side orientation defined at construction time
  20621. */
  20622. overrideMaterialSideOrientation: Nullable<number>;
  20623. private _areNormalsFrozen;
  20624. private _sourcePositions;
  20625. private _sourceNormals;
  20626. private _source;
  20627. private meshMap;
  20628. /**
  20629. * Gets the source mesh (the one used to clone this one from)
  20630. */
  20631. readonly source: Nullable<Mesh>;
  20632. /**
  20633. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20634. */
  20635. isUnIndexed: boolean;
  20636. /**
  20637. * @constructor
  20638. * @param name The value used by scene.getMeshByName() to do a lookup.
  20639. * @param scene The scene to add this mesh to.
  20640. * @param parent The parent of this mesh, if it has one
  20641. * @param source An optional Mesh from which geometry is shared, cloned.
  20642. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20643. * When false, achieved by calling a clone(), also passing False.
  20644. * This will make creation of children, recursive.
  20645. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20646. */
  20647. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20648. /**
  20649. * Gets the class name
  20650. * @returns the string "Mesh".
  20651. */
  20652. getClassName(): string;
  20653. /** @hidden */ protected readonly _isMesh: boolean;
  20654. /**
  20655. * Returns a description of this mesh
  20656. * @param fullDetails define if full details about this mesh must be used
  20657. * @returns a descriptive string representing this mesh
  20658. */
  20659. toString(fullDetails?: boolean): string;
  20660. /** @hidden */ unBindEffect(): void;
  20661. /**
  20662. * Gets a boolean indicating if this mesh has LOD
  20663. */
  20664. readonly hasLODLevels: boolean;
  20665. /**
  20666. * Gets the list of MeshLODLevel associated with the current mesh
  20667. * @returns an array of MeshLODLevel
  20668. */
  20669. getLODLevels(): MeshLODLevel[];
  20670. private _sortLODLevels;
  20671. /**
  20672. * Add a mesh as LOD level triggered at the given distance.
  20673. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20674. * @param distance The distance from the center of the object to show this level
  20675. * @param mesh The mesh to be added as LOD level (can be null)
  20676. * @return This mesh (for chaining)
  20677. */
  20678. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20679. /**
  20680. * Returns the LOD level mesh at the passed distance or null if not found.
  20681. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20682. * @param distance The distance from the center of the object to show this level
  20683. * @returns a Mesh or `null`
  20684. */
  20685. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20686. /**
  20687. * Remove a mesh from the LOD array
  20688. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20689. * @param mesh defines the mesh to be removed
  20690. * @return This mesh (for chaining)
  20691. */
  20692. removeLODLevel(mesh: Mesh): Mesh;
  20693. /**
  20694. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20695. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20696. * @param camera defines the camera to use to compute distance
  20697. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20698. * @return This mesh (for chaining)
  20699. */
  20700. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20701. /**
  20702. * Gets the mesh internal Geometry object
  20703. */
  20704. readonly geometry: Nullable<Geometry>;
  20705. /**
  20706. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20707. * @returns the total number of vertices
  20708. */
  20709. getTotalVertices(): number;
  20710. /**
  20711. * Returns the content of an associated vertex buffer
  20712. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20713. * - VertexBuffer.PositionKind
  20714. * - VertexBuffer.UVKind
  20715. * - VertexBuffer.UV2Kind
  20716. * - VertexBuffer.UV3Kind
  20717. * - VertexBuffer.UV4Kind
  20718. * - VertexBuffer.UV5Kind
  20719. * - VertexBuffer.UV6Kind
  20720. * - VertexBuffer.ColorKind
  20721. * - VertexBuffer.MatricesIndicesKind
  20722. * - VertexBuffer.MatricesIndicesExtraKind
  20723. * - VertexBuffer.MatricesWeightsKind
  20724. * - VertexBuffer.MatricesWeightsExtraKind
  20725. * @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
  20726. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20727. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20728. */
  20729. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20730. /**
  20731. * Returns the mesh VertexBuffer object from the requested `kind`
  20732. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20733. * - VertexBuffer.PositionKind
  20734. * - VertexBuffer.UVKind
  20735. * - VertexBuffer.UV2Kind
  20736. * - VertexBuffer.UV3Kind
  20737. * - VertexBuffer.UV4Kind
  20738. * - VertexBuffer.UV5Kind
  20739. * - VertexBuffer.UV6Kind
  20740. * - VertexBuffer.ColorKind
  20741. * - VertexBuffer.MatricesIndicesKind
  20742. * - VertexBuffer.MatricesIndicesExtraKind
  20743. * - VertexBuffer.MatricesWeightsKind
  20744. * - VertexBuffer.MatricesWeightsExtraKind
  20745. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20746. */
  20747. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20748. /**
  20749. * Tests if a specific vertex buffer is associated with this mesh
  20750. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20751. * - VertexBuffer.PositionKind
  20752. * - VertexBuffer.UVKind
  20753. * - VertexBuffer.UV2Kind
  20754. * - VertexBuffer.UV3Kind
  20755. * - VertexBuffer.UV4Kind
  20756. * - VertexBuffer.UV5Kind
  20757. * - VertexBuffer.UV6Kind
  20758. * - VertexBuffer.ColorKind
  20759. * - VertexBuffer.MatricesIndicesKind
  20760. * - VertexBuffer.MatricesIndicesExtraKind
  20761. * - VertexBuffer.MatricesWeightsKind
  20762. * - VertexBuffer.MatricesWeightsExtraKind
  20763. * @returns a boolean
  20764. */
  20765. isVerticesDataPresent(kind: string): boolean;
  20766. /**
  20767. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20768. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20769. * - VertexBuffer.PositionKind
  20770. * - VertexBuffer.UVKind
  20771. * - VertexBuffer.UV2Kind
  20772. * - VertexBuffer.UV3Kind
  20773. * - VertexBuffer.UV4Kind
  20774. * - VertexBuffer.UV5Kind
  20775. * - VertexBuffer.UV6Kind
  20776. * - VertexBuffer.ColorKind
  20777. * - VertexBuffer.MatricesIndicesKind
  20778. * - VertexBuffer.MatricesIndicesExtraKind
  20779. * - VertexBuffer.MatricesWeightsKind
  20780. * - VertexBuffer.MatricesWeightsExtraKind
  20781. * @returns a boolean
  20782. */
  20783. isVertexBufferUpdatable(kind: string): boolean;
  20784. /**
  20785. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20786. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20787. * - VertexBuffer.PositionKind
  20788. * - VertexBuffer.UVKind
  20789. * - VertexBuffer.UV2Kind
  20790. * - VertexBuffer.UV3Kind
  20791. * - VertexBuffer.UV4Kind
  20792. * - VertexBuffer.UV5Kind
  20793. * - VertexBuffer.UV6Kind
  20794. * - VertexBuffer.ColorKind
  20795. * - VertexBuffer.MatricesIndicesKind
  20796. * - VertexBuffer.MatricesIndicesExtraKind
  20797. * - VertexBuffer.MatricesWeightsKind
  20798. * - VertexBuffer.MatricesWeightsExtraKind
  20799. * @returns an array of strings
  20800. */
  20801. getVerticesDataKinds(): string[];
  20802. /**
  20803. * Returns a positive integer : the total number of indices in this mesh geometry.
  20804. * @returns the numner of indices or zero if the mesh has no geometry.
  20805. */
  20806. getTotalIndices(): number;
  20807. /**
  20808. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20809. * @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.
  20810. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20811. * @returns the indices array or an empty array if the mesh has no geometry
  20812. */
  20813. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20814. readonly isBlocked: boolean;
  20815. /**
  20816. * Determine if the current mesh is ready to be rendered
  20817. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20818. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20819. * @returns true if all associated assets are ready (material, textures, shaders)
  20820. */
  20821. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20822. /**
  20823. * 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.
  20824. */
  20825. readonly areNormalsFrozen: boolean;
  20826. /**
  20827. * 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.
  20828. * @returns the current mesh
  20829. */
  20830. freezeNormals(): Mesh;
  20831. /**
  20832. * 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
  20833. * @returns the current mesh
  20834. */
  20835. unfreezeNormals(): Mesh;
  20836. /**
  20837. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20838. */
  20839. overridenInstanceCount: number;
  20840. /** @hidden */ preActivate(): Mesh;
  20841. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  20842. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20843. /**
  20844. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20845. * This means the mesh underlying bounding box and sphere are recomputed.
  20846. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20847. * @returns the current mesh
  20848. */
  20849. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20850. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20851. /**
  20852. * This function will subdivide the mesh into multiple submeshes
  20853. * @param count defines the expected number of submeshes
  20854. */
  20855. subdivide(count: number): void;
  20856. /**
  20857. * Copy a FloatArray into a specific associated vertex buffer
  20858. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20859. * - VertexBuffer.PositionKind
  20860. * - VertexBuffer.UVKind
  20861. * - VertexBuffer.UV2Kind
  20862. * - VertexBuffer.UV3Kind
  20863. * - VertexBuffer.UV4Kind
  20864. * - VertexBuffer.UV5Kind
  20865. * - VertexBuffer.UV6Kind
  20866. * - VertexBuffer.ColorKind
  20867. * - VertexBuffer.MatricesIndicesKind
  20868. * - VertexBuffer.MatricesIndicesExtraKind
  20869. * - VertexBuffer.MatricesWeightsKind
  20870. * - VertexBuffer.MatricesWeightsExtraKind
  20871. * @param data defines the data source
  20872. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20873. * @param stride defines the data stride size (can be null)
  20874. * @returns the current mesh
  20875. */
  20876. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20877. /**
  20878. * Flags an associated vertex buffer as updatable
  20879. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20880. * - VertexBuffer.PositionKind
  20881. * - VertexBuffer.UVKind
  20882. * - VertexBuffer.UV2Kind
  20883. * - VertexBuffer.UV3Kind
  20884. * - VertexBuffer.UV4Kind
  20885. * - VertexBuffer.UV5Kind
  20886. * - VertexBuffer.UV6Kind
  20887. * - VertexBuffer.ColorKind
  20888. * - VertexBuffer.MatricesIndicesKind
  20889. * - VertexBuffer.MatricesIndicesExtraKind
  20890. * - VertexBuffer.MatricesWeightsKind
  20891. * - VertexBuffer.MatricesWeightsExtraKind
  20892. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20893. */
  20894. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20895. /**
  20896. * Sets the mesh global Vertex Buffer
  20897. * @param buffer defines the buffer to use
  20898. * @returns the current mesh
  20899. */
  20900. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20901. /**
  20902. * Update a specific associated vertex buffer
  20903. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20904. * - VertexBuffer.PositionKind
  20905. * - VertexBuffer.UVKind
  20906. * - VertexBuffer.UV2Kind
  20907. * - VertexBuffer.UV3Kind
  20908. * - VertexBuffer.UV4Kind
  20909. * - VertexBuffer.UV5Kind
  20910. * - VertexBuffer.UV6Kind
  20911. * - VertexBuffer.ColorKind
  20912. * - VertexBuffer.MatricesIndicesKind
  20913. * - VertexBuffer.MatricesIndicesExtraKind
  20914. * - VertexBuffer.MatricesWeightsKind
  20915. * - VertexBuffer.MatricesWeightsExtraKind
  20916. * @param data defines the data source
  20917. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20918. * @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)
  20919. * @returns the current mesh
  20920. */
  20921. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20922. /**
  20923. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20924. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20925. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20926. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20927. * @returns the current mesh
  20928. */
  20929. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20930. /**
  20931. * Creates a un-shared specific occurence of the geometry for the mesh.
  20932. * @returns the current mesh
  20933. */
  20934. makeGeometryUnique(): Mesh;
  20935. /**
  20936. * Set the index buffer of this mesh
  20937. * @param indices defines the source data
  20938. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20939. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20940. * @returns the current mesh
  20941. */
  20942. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20943. /**
  20944. * Update the current index buffer
  20945. * @param indices defines the source data
  20946. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20947. * @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)
  20948. * @returns the current mesh
  20949. */
  20950. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20951. /**
  20952. * Invert the geometry to move from a right handed system to a left handed one.
  20953. * @returns the current mesh
  20954. */
  20955. toLeftHanded(): Mesh;
  20956. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20957. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20958. /**
  20959. * Registers for this mesh a javascript function called just before the rendering process
  20960. * @param func defines the function to call before rendering this mesh
  20961. * @returns the current mesh
  20962. */
  20963. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20964. /**
  20965. * Disposes a previously registered javascript function called before the rendering
  20966. * @param func defines the function to remove
  20967. * @returns the current mesh
  20968. */
  20969. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20970. /**
  20971. * Registers for this mesh a javascript function called just after the rendering is complete
  20972. * @param func defines the function to call after rendering this mesh
  20973. * @returns the current mesh
  20974. */
  20975. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20976. /**
  20977. * Disposes a previously registered javascript function called after the rendering.
  20978. * @param func defines the function to remove
  20979. * @returns the current mesh
  20980. */
  20981. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20982. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20983. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20984. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20985. /** @hidden */ freeze(): void;
  20986. /** @hidden */ unFreeze(): void;
  20987. /**
  20988. * 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
  20989. * @param subMesh defines the subMesh to render
  20990. * @param enableAlphaMode defines if alpha mode can be changed
  20991. * @returns the current mesh
  20992. */
  20993. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20994. private _onBeforeDraw;
  20995. /**
  20996. * Renormalize the mesh and patch it up if there are no weights
  20997. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20998. * However in the case of zero weights then we set just a single influence to 1.
  20999. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21000. */
  21001. cleanMatrixWeights(): void;
  21002. private normalizeSkinFourWeights;
  21003. private normalizeSkinWeightsAndExtra;
  21004. /**
  21005. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21006. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21007. * the user know there was an issue with importing the mesh
  21008. * @returns a validation object with skinned, valid and report string
  21009. */
  21010. validateSkinning(): {
  21011. skinned: boolean;
  21012. valid: boolean;
  21013. report: string;
  21014. };
  21015. /** @hidden */ checkDelayState(): Mesh;
  21016. private _queueLoad;
  21017. /**
  21018. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21019. * A mesh is in the frustum if its bounding box intersects the frustum
  21020. * @param frustumPlanes defines the frustum to test
  21021. * @returns true if the mesh is in the frustum planes
  21022. */
  21023. isInFrustum(frustumPlanes: Plane[]): boolean;
  21024. /**
  21025. * Sets the mesh material by the material or multiMaterial `id` property
  21026. * @param id is a string identifying the material or the multiMaterial
  21027. * @returns the current mesh
  21028. */
  21029. setMaterialByID(id: string): Mesh;
  21030. /**
  21031. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21032. * @returns an array of IAnimatable
  21033. */
  21034. getAnimatables(): IAnimatable[];
  21035. /**
  21036. * Modifies the mesh geometry according to the passed transformation matrix.
  21037. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21038. * The mesh normals are modified using the same transformation.
  21039. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21040. * @param transform defines the transform matrix to use
  21041. * @see http://doc.babylonjs.com/resources/baking_transformations
  21042. * @returns the current mesh
  21043. */
  21044. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21045. /**
  21046. * Modifies the mesh geometry according to its own current World Matrix.
  21047. * The mesh World Matrix is then reset.
  21048. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21049. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21050. * @see http://doc.babylonjs.com/resources/baking_transformations
  21051. * @returns the current mesh
  21052. */
  21053. bakeCurrentTransformIntoVertices(): Mesh;
  21054. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  21055. /** @hidden */ resetPointsArrayCache(): Mesh;
  21056. /** @hidden */ generatePointsArray(): boolean;
  21057. /**
  21058. * Returns a new Mesh object generated from the current mesh properties.
  21059. * This method must not get confused with createInstance()
  21060. * @param name is a string, the name given to the new mesh
  21061. * @param newParent can be any Node object (default `null`)
  21062. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21063. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21064. * @returns a new mesh
  21065. */
  21066. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21067. /**
  21068. * Releases resources associated with this mesh.
  21069. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21070. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21071. */
  21072. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21073. /**
  21074. * Modifies the mesh geometry according to a displacement map.
  21075. * 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.
  21076. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21077. * @param url is a string, the URL from the image file is to be downloaded.
  21078. * @param minHeight is the lower limit of the displacement.
  21079. * @param maxHeight is the upper limit of the displacement.
  21080. * @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.
  21081. * @param uvOffset is an optional vector2 used to offset UV.
  21082. * @param uvScale is an optional vector2 used to scale UV.
  21083. * @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.
  21084. * @returns the Mesh.
  21085. */
  21086. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21087. /**
  21088. * Modifies the mesh geometry according to a displacementMap buffer.
  21089. * 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.
  21090. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21091. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21092. * @param heightMapWidth is the width of the buffer image.
  21093. * @param heightMapHeight is the height of the buffer image.
  21094. * @param minHeight is the lower limit of the displacement.
  21095. * @param maxHeight is the upper limit of the displacement.
  21096. * @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.
  21097. * @param uvOffset is an optional vector2 used to offset UV.
  21098. * @param uvScale is an optional vector2 used to scale UV.
  21099. * @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.
  21100. * @returns the Mesh.
  21101. */
  21102. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21103. /**
  21104. * Modify the mesh to get a flat shading rendering.
  21105. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21106. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21107. * @returns current mesh
  21108. */
  21109. convertToFlatShadedMesh(): Mesh;
  21110. /**
  21111. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21112. * In other words, more vertices, no more indices and a single bigger VBO.
  21113. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21114. * @returns current mesh
  21115. */
  21116. convertToUnIndexedMesh(): Mesh;
  21117. /**
  21118. * Inverses facet orientations.
  21119. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21120. * @param flipNormals will also inverts the normals
  21121. * @returns current mesh
  21122. */
  21123. flipFaces(flipNormals?: boolean): Mesh;
  21124. /**
  21125. * Increase the number of facets and hence vertices in a mesh
  21126. * Vertex normals are interpolated from existing vertex normals
  21127. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21128. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21129. */
  21130. increaseVertices(numberPerEdge: number): void;
  21131. /**
  21132. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21133. * This will undo any application of covertToFlatShadedMesh
  21134. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21135. */
  21136. forceSharedVertices(): void;
  21137. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21138. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21139. /**
  21140. * Creates a new InstancedMesh object from the mesh model.
  21141. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21142. * @param name defines the name of the new instance
  21143. * @returns a new InstancedMesh
  21144. */
  21145. createInstance(name: string): InstancedMesh;
  21146. /**
  21147. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21148. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21149. * @returns the current mesh
  21150. */
  21151. synchronizeInstances(): Mesh;
  21152. /**
  21153. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21154. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21155. * This should be used together with the simplification to avoid disappearing triangles.
  21156. * @param successCallback an optional success callback to be called after the optimization finished.
  21157. * @returns the current mesh
  21158. */
  21159. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21160. /**
  21161. * Serialize current mesh
  21162. * @param serializationObject defines the object which will receive the serialization data
  21163. */
  21164. serialize(serializationObject: any): void;
  21165. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  21166. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21167. /**
  21168. * Returns a new Mesh object parsed from the source provided.
  21169. * @param parsedMesh is the source
  21170. * @param scene defines the hosting scene
  21171. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21172. * @returns a new Mesh
  21173. */
  21174. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21175. /**
  21176. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21177. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21178. * @param name defines the name of the mesh to create
  21179. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21180. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21181. * @param closePath creates a seam between the first and the last points of each path of the path array
  21182. * @param offset is taken in account only if the `pathArray` is containing a single path
  21183. * @param scene defines the hosting scene
  21184. * @param updatable defines if the mesh must be flagged as updatable
  21185. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21186. * @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)
  21187. * @returns a new Mesh
  21188. */
  21189. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21190. /**
  21191. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21192. * @param name defines the name of the mesh to create
  21193. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21194. * @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
  21195. * @param scene defines the hosting scene
  21196. * @param updatable defines if the mesh must be flagged as updatable
  21197. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21198. * @returns a new Mesh
  21199. */
  21200. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21201. /**
  21202. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21203. * @param name defines the name of the mesh to create
  21204. * @param size sets the size (float) of each box side (default 1)
  21205. * @param scene defines the hosting scene
  21206. * @param updatable defines if the mesh must be flagged as updatable
  21207. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21208. * @returns a new Mesh
  21209. */
  21210. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21211. /**
  21212. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21213. * @param name defines the name of the mesh to create
  21214. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21215. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21216. * @param scene defines the hosting scene
  21217. * @param updatable defines if the mesh must be flagged as updatable
  21218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21219. * @returns a new Mesh
  21220. */
  21221. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21222. /**
  21223. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21224. * @param name defines the name of the mesh to create
  21225. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21226. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21227. * @param scene defines the hosting scene
  21228. * @returns a new Mesh
  21229. */
  21230. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21231. /**
  21232. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21233. * @param name defines the name of the mesh to create
  21234. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21235. * @param diameterTop set the top cap diameter (floats, default 1)
  21236. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21237. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21238. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21239. * @param scene defines the hosting scene
  21240. * @param updatable defines if the mesh must be flagged as updatable
  21241. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21242. * @returns a new Mesh
  21243. */
  21244. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21245. /**
  21246. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21247. * @param name defines the name of the mesh to create
  21248. * @param diameter sets the diameter size (float) of the torus (default 1)
  21249. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21250. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21251. * @param scene defines the hosting scene
  21252. * @param updatable defines if the mesh must be flagged as updatable
  21253. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21254. * @returns a new Mesh
  21255. */
  21256. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21257. /**
  21258. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21259. * @param name defines the name of the mesh to create
  21260. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21261. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21262. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21263. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21264. * @param p the number of windings on X axis (positive integers, default 2)
  21265. * @param q the number of windings on Y axis (positive integers, default 3)
  21266. * @param scene defines the hosting scene
  21267. * @param updatable defines if the mesh must be flagged as updatable
  21268. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21269. * @returns a new Mesh
  21270. */
  21271. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21272. /**
  21273. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21274. * @param name defines the name of the mesh to create
  21275. * @param points is an array successive Vector3
  21276. * @param scene defines the hosting scene
  21277. * @param updatable defines if the mesh must be flagged as updatable
  21278. * @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).
  21279. * @returns a new Mesh
  21280. */
  21281. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21282. /**
  21283. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21284. * @param name defines the name of the mesh to create
  21285. * @param points is an array successive Vector3
  21286. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21287. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21288. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21289. * @param scene defines the hosting scene
  21290. * @param updatable defines if the mesh must be flagged as updatable
  21291. * @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)
  21292. * @returns a new Mesh
  21293. */
  21294. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21295. /**
  21296. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21297. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21298. * 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.
  21299. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21300. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21301. * Remember you can only change the shape positions, not their number when updating a polygon.
  21302. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21303. * @param name defines the name of the mesh to create
  21304. * @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
  21305. * @param scene defines the hosting scene
  21306. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21307. * @param updatable defines if the mesh must be flagged as updatable
  21308. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21309. * @param earcutInjection can be used to inject your own earcut reference
  21310. * @returns a new Mesh
  21311. */
  21312. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21313. /**
  21314. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21315. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21316. * @param name defines the name of the mesh to create
  21317. * @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
  21318. * @param depth defines the height of extrusion
  21319. * @param scene defines the hosting scene
  21320. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21321. * @param updatable defines if the mesh must be flagged as updatable
  21322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21323. * @param earcutInjection can be used to inject your own earcut reference
  21324. * @returns a new Mesh
  21325. */
  21326. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21327. /**
  21328. * Creates an extruded shape mesh.
  21329. * 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
  21330. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21331. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21332. * @param name defines the name of the mesh to create
  21333. * @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
  21334. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21335. * @param scale is the value to scale the shape
  21336. * @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
  21337. * @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
  21338. * @param scene defines the hosting scene
  21339. * @param updatable defines if the mesh must be flagged as updatable
  21340. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21341. * @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)
  21342. * @returns a new Mesh
  21343. */
  21344. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21345. /**
  21346. * Creates an custom extruded shape mesh.
  21347. * The custom extrusion is a parametric shape.
  21348. * It has no predefined shape. Its final shape will depend on the input parameters.
  21349. * Please consider using the same method from the MeshBuilder class instead
  21350. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21351. * @param name defines the name of the mesh to create
  21352. * @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
  21353. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21354. * @param scaleFunction is a custom Javascript function called on each path point
  21355. * @param rotationFunction is a custom Javascript function called on each path point
  21356. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21357. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21358. * @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
  21359. * @param scene defines the hosting scene
  21360. * @param updatable defines if the mesh must be flagged as updatable
  21361. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21362. * @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)
  21363. * @returns a new Mesh
  21364. */
  21365. 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;
  21366. /**
  21367. * Creates lathe mesh.
  21368. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21369. * Please consider using the same method from the MeshBuilder class instead
  21370. * @param name defines the name of the mesh to create
  21371. * @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
  21372. * @param radius is the radius value of the lathe
  21373. * @param tessellation is the side number of the lathe.
  21374. * @param scene defines the hosting scene
  21375. * @param updatable defines if the mesh must be flagged as updatable
  21376. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21377. * @returns a new Mesh
  21378. */
  21379. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21380. /**
  21381. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21382. * @param name defines the name of the mesh to create
  21383. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21384. * @param scene defines the hosting scene
  21385. * @param updatable defines if the mesh must be flagged as updatable
  21386. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21387. * @returns a new Mesh
  21388. */
  21389. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21390. /**
  21391. * Creates a ground mesh.
  21392. * Please consider using the same method from the MeshBuilder class instead
  21393. * @param name defines the name of the mesh to create
  21394. * @param width set the width of the ground
  21395. * @param height set the height of the ground
  21396. * @param subdivisions sets the number of subdivisions per side
  21397. * @param scene defines the hosting scene
  21398. * @param updatable defines if the mesh must be flagged as updatable
  21399. * @returns a new Mesh
  21400. */
  21401. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21402. /**
  21403. * Creates a tiled ground mesh.
  21404. * Please consider using the same method from the MeshBuilder class instead
  21405. * @param name defines the name of the mesh to create
  21406. * @param xmin set the ground minimum X coordinate
  21407. * @param zmin set the ground minimum Y coordinate
  21408. * @param xmax set the ground maximum X coordinate
  21409. * @param zmax set the ground maximum Z coordinate
  21410. * @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
  21411. * @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
  21412. * @param scene defines the hosting scene
  21413. * @param updatable defines if the mesh must be flagged as updatable
  21414. * @returns a new Mesh
  21415. */
  21416. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21417. w: number;
  21418. h: number;
  21419. }, precision: {
  21420. w: number;
  21421. h: number;
  21422. }, scene: Scene, updatable?: boolean): Mesh;
  21423. /**
  21424. * Creates a ground mesh from a height map.
  21425. * Please consider using the same method from the MeshBuilder class instead
  21426. * @see http://doc.babylonjs.com/babylon101/height_map
  21427. * @param name defines the name of the mesh to create
  21428. * @param url sets the URL of the height map image resource
  21429. * @param width set the ground width size
  21430. * @param height set the ground height size
  21431. * @param subdivisions sets the number of subdivision per side
  21432. * @param minHeight is the minimum altitude on the ground
  21433. * @param maxHeight is the maximum altitude on the ground
  21434. * @param scene defines the hosting scene
  21435. * @param updatable defines if the mesh must be flagged as updatable
  21436. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21437. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21438. * @returns a new Mesh
  21439. */
  21440. 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;
  21441. /**
  21442. * Creates a tube mesh.
  21443. * The tube is a parametric shape.
  21444. * It has no predefined shape. Its final shape will depend on the input parameters.
  21445. * Please consider using the same method from the MeshBuilder class instead
  21446. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21447. * @param name defines the name of the mesh to create
  21448. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21449. * @param radius sets the tube radius size
  21450. * @param tessellation is the number of sides on the tubular surface
  21451. * @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
  21452. * @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
  21453. * @param scene defines the hosting scene
  21454. * @param updatable defines if the mesh must be flagged as updatable
  21455. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21456. * @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)
  21457. * @returns a new Mesh
  21458. */
  21459. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21460. (i: number, distance: number): number;
  21461. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21462. /**
  21463. * Creates a polyhedron mesh.
  21464. * Please consider using the same method from the MeshBuilder class instead.
  21465. * * 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
  21466. * * The parameter `size` (positive float, default 1) sets the polygon size
  21467. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21468. * * 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`
  21469. * * 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
  21470. * * 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)`)
  21471. * * 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
  21472. * * 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
  21473. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21474. * * 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
  21475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21476. * @param name defines the name of the mesh to create
  21477. * @param options defines the options used to create the mesh
  21478. * @param scene defines the hosting scene
  21479. * @returns a new Mesh
  21480. */
  21481. static CreatePolyhedron(name: string, options: {
  21482. type?: number;
  21483. size?: number;
  21484. sizeX?: number;
  21485. sizeY?: number;
  21486. sizeZ?: number;
  21487. custom?: any;
  21488. faceUV?: Vector4[];
  21489. faceColors?: Color4[];
  21490. updatable?: boolean;
  21491. sideOrientation?: number;
  21492. }, scene: Scene): Mesh;
  21493. /**
  21494. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21495. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21496. * * 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`)
  21497. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21498. * * 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
  21499. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21500. * * 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
  21501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21502. * @param name defines the name of the mesh
  21503. * @param options defines the options used to create the mesh
  21504. * @param scene defines the hosting scene
  21505. * @returns a new Mesh
  21506. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21507. */
  21508. static CreateIcoSphere(name: string, options: {
  21509. radius?: number;
  21510. flat?: boolean;
  21511. subdivisions?: number;
  21512. sideOrientation?: number;
  21513. updatable?: boolean;
  21514. }, scene: Scene): Mesh;
  21515. /**
  21516. * Creates a decal mesh.
  21517. * Please consider using the same method from the MeshBuilder class instead.
  21518. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21519. * @param name defines the name of the mesh
  21520. * @param sourceMesh defines the mesh receiving the decal
  21521. * @param position sets the position of the decal in world coordinates
  21522. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21523. * @param size sets the decal scaling
  21524. * @param angle sets the angle to rotate the decal
  21525. * @returns a new Mesh
  21526. */
  21527. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21528. /**
  21529. * Prepare internal position array for software CPU skinning
  21530. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21531. */
  21532. setPositionsForCPUSkinning(): Float32Array;
  21533. /**
  21534. * Prepare internal normal array for software CPU skinning
  21535. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21536. */
  21537. setNormalsForCPUSkinning(): Float32Array;
  21538. /**
  21539. * Updates the vertex buffer by applying transformation from the bones
  21540. * @param skeleton defines the skeleton to apply to current mesh
  21541. * @returns the current mesh
  21542. */
  21543. applySkeleton(skeleton: Skeleton): Mesh;
  21544. /**
  21545. * 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
  21546. * @param meshes defines the list of meshes to scan
  21547. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21548. */
  21549. static MinMax(meshes: AbstractMesh[]): {
  21550. min: Vector3;
  21551. max: Vector3;
  21552. };
  21553. /**
  21554. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21555. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21556. * @returns a vector3
  21557. */
  21558. static Center(meshesOrMinMaxVector: {
  21559. min: Vector3;
  21560. max: Vector3;
  21561. } | AbstractMesh[]): Vector3;
  21562. /**
  21563. * Merge the array of meshes into a single mesh for performance reasons.
  21564. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21565. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21566. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21567. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21568. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21569. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21570. * @returns a new mesh
  21571. */
  21572. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21573. /** @hidden */
  21574. addInstance(instance: InstancedMesh): void;
  21575. /** @hidden */
  21576. removeInstance(instance: InstancedMesh): void;
  21577. }
  21578. }
  21579. declare module BABYLON {
  21580. /**
  21581. * Base class for the main features of a material in Babylon.js
  21582. */
  21583. export class Material implements IAnimatable {
  21584. /**
  21585. * Returns the triangle fill mode
  21586. */
  21587. static readonly TriangleFillMode: number;
  21588. /**
  21589. * Returns the wireframe mode
  21590. */
  21591. static readonly WireFrameFillMode: number;
  21592. /**
  21593. * Returns the point fill mode
  21594. */
  21595. static readonly PointFillMode: number;
  21596. /**
  21597. * Returns the point list draw mode
  21598. */
  21599. static readonly PointListDrawMode: number;
  21600. /**
  21601. * Returns the line list draw mode
  21602. */
  21603. static readonly LineListDrawMode: number;
  21604. /**
  21605. * Returns the line loop draw mode
  21606. */
  21607. static readonly LineLoopDrawMode: number;
  21608. /**
  21609. * Returns the line strip draw mode
  21610. */
  21611. static readonly LineStripDrawMode: number;
  21612. /**
  21613. * Returns the triangle strip draw mode
  21614. */
  21615. static readonly TriangleStripDrawMode: number;
  21616. /**
  21617. * Returns the triangle fan draw mode
  21618. */
  21619. static readonly TriangleFanDrawMode: number;
  21620. /**
  21621. * Stores the clock-wise side orientation
  21622. */
  21623. static readonly ClockWiseSideOrientation: number;
  21624. /**
  21625. * Stores the counter clock-wise side orientation
  21626. */
  21627. static readonly CounterClockWiseSideOrientation: number;
  21628. /**
  21629. * The dirty texture flag value
  21630. */
  21631. static readonly TextureDirtyFlag: number;
  21632. /**
  21633. * The dirty light flag value
  21634. */
  21635. static readonly LightDirtyFlag: number;
  21636. /**
  21637. * The dirty fresnel flag value
  21638. */
  21639. static readonly FresnelDirtyFlag: number;
  21640. /**
  21641. * The dirty attribute flag value
  21642. */
  21643. static readonly AttributesDirtyFlag: number;
  21644. /**
  21645. * The dirty misc flag value
  21646. */
  21647. static readonly MiscDirtyFlag: number;
  21648. /**
  21649. * The all dirty flag value
  21650. */
  21651. static readonly AllDirtyFlag: number;
  21652. /**
  21653. * The ID of the material
  21654. */
  21655. id: string;
  21656. /**
  21657. * Gets or sets the unique id of the material
  21658. */
  21659. uniqueId: number;
  21660. /**
  21661. * The name of the material
  21662. */
  21663. name: string;
  21664. /**
  21665. * Gets or sets user defined metadata
  21666. */
  21667. metadata: any;
  21668. /**
  21669. * For internal use only. Please do not use.
  21670. */
  21671. reservedDataStore: any;
  21672. /**
  21673. * Specifies if the ready state should be checked on each call
  21674. */
  21675. checkReadyOnEveryCall: boolean;
  21676. /**
  21677. * Specifies if the ready state should be checked once
  21678. */
  21679. checkReadyOnlyOnce: boolean;
  21680. /**
  21681. * The state of the material
  21682. */
  21683. state: string;
  21684. /**
  21685. * The alpha value of the material
  21686. */
  21687. protected _alpha: number;
  21688. /**
  21689. * List of inspectable custom properties (used by the Inspector)
  21690. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21691. */
  21692. inspectableCustomProperties: IInspectable[];
  21693. /**
  21694. * Sets the alpha value of the material
  21695. */
  21696. /**
  21697. * Gets the alpha value of the material
  21698. */
  21699. alpha: number;
  21700. /**
  21701. * Specifies if back face culling is enabled
  21702. */
  21703. protected _backFaceCulling: boolean;
  21704. /**
  21705. * Sets the back-face culling state
  21706. */
  21707. /**
  21708. * Gets the back-face culling state
  21709. */
  21710. backFaceCulling: boolean;
  21711. /**
  21712. * Stores the value for side orientation
  21713. */
  21714. sideOrientation: number;
  21715. /**
  21716. * Callback triggered when the material is compiled
  21717. */
  21718. onCompiled: Nullable<(effect: Effect) => void>;
  21719. /**
  21720. * Callback triggered when an error occurs
  21721. */
  21722. onError: Nullable<(effect: Effect, errors: string) => void>;
  21723. /**
  21724. * Callback triggered to get the render target textures
  21725. */
  21726. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21727. /**
  21728. * Gets a boolean indicating that current material needs to register RTT
  21729. */
  21730. readonly hasRenderTargetTextures: boolean;
  21731. /**
  21732. * Specifies if the material should be serialized
  21733. */
  21734. doNotSerialize: boolean;
  21735. /**
  21736. * @hidden
  21737. */ storeEffectOnSubMeshes: boolean;
  21738. /**
  21739. * Stores the animations for the material
  21740. */
  21741. animations: Nullable<Array<Animation>>;
  21742. /**
  21743. * An event triggered when the material is disposed
  21744. */
  21745. onDisposeObservable: Observable<Material>;
  21746. /**
  21747. * An observer which watches for dispose events
  21748. */
  21749. private _onDisposeObserver;
  21750. private _onUnBindObservable;
  21751. /**
  21752. * Called during a dispose event
  21753. */
  21754. onDispose: () => void;
  21755. private _onBindObservable;
  21756. /**
  21757. * An event triggered when the material is bound
  21758. */
  21759. readonly onBindObservable: Observable<AbstractMesh>;
  21760. /**
  21761. * An observer which watches for bind events
  21762. */
  21763. private _onBindObserver;
  21764. /**
  21765. * Called during a bind event
  21766. */
  21767. onBind: (Mesh: AbstractMesh) => void;
  21768. /**
  21769. * An event triggered when the material is unbound
  21770. */
  21771. readonly onUnBindObservable: Observable<Material>;
  21772. /**
  21773. * Stores the value of the alpha mode
  21774. */
  21775. private _alphaMode;
  21776. /**
  21777. * Sets the value of the alpha mode.
  21778. *
  21779. * | Value | Type | Description |
  21780. * | --- | --- | --- |
  21781. * | 0 | ALPHA_DISABLE | |
  21782. * | 1 | ALPHA_ADD | |
  21783. * | 2 | ALPHA_COMBINE | |
  21784. * | 3 | ALPHA_SUBTRACT | |
  21785. * | 4 | ALPHA_MULTIPLY | |
  21786. * | 5 | ALPHA_MAXIMIZED | |
  21787. * | 6 | ALPHA_ONEONE | |
  21788. * | 7 | ALPHA_PREMULTIPLIED | |
  21789. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21790. * | 9 | ALPHA_INTERPOLATE | |
  21791. * | 10 | ALPHA_SCREENMODE | |
  21792. *
  21793. */
  21794. /**
  21795. * Gets the value of the alpha mode
  21796. */
  21797. alphaMode: number;
  21798. /**
  21799. * Stores the state of the need depth pre-pass value
  21800. */
  21801. private _needDepthPrePass;
  21802. /**
  21803. * Sets the need depth pre-pass value
  21804. */
  21805. /**
  21806. * Gets the depth pre-pass value
  21807. */
  21808. needDepthPrePass: boolean;
  21809. /**
  21810. * Specifies if depth writing should be disabled
  21811. */
  21812. disableDepthWrite: boolean;
  21813. /**
  21814. * Specifies if depth writing should be forced
  21815. */
  21816. forceDepthWrite: boolean;
  21817. /**
  21818. * Specifies if there should be a separate pass for culling
  21819. */
  21820. separateCullingPass: boolean;
  21821. /**
  21822. * Stores the state specifing if fog should be enabled
  21823. */
  21824. private _fogEnabled;
  21825. /**
  21826. * Sets the state for enabling fog
  21827. */
  21828. /**
  21829. * Gets the value of the fog enabled state
  21830. */
  21831. fogEnabled: boolean;
  21832. /**
  21833. * Stores the size of points
  21834. */
  21835. pointSize: number;
  21836. /**
  21837. * Stores the z offset value
  21838. */
  21839. zOffset: number;
  21840. /**
  21841. * Gets a value specifying if wireframe mode is enabled
  21842. */
  21843. /**
  21844. * Sets the state of wireframe mode
  21845. */
  21846. wireframe: boolean;
  21847. /**
  21848. * Gets the value specifying if point clouds are enabled
  21849. */
  21850. /**
  21851. * Sets the state of point cloud mode
  21852. */
  21853. pointsCloud: boolean;
  21854. /**
  21855. * Gets the material fill mode
  21856. */
  21857. /**
  21858. * Sets the material fill mode
  21859. */
  21860. fillMode: number;
  21861. /**
  21862. * @hidden
  21863. * Stores the effects for the material
  21864. */ effect: Nullable<Effect>;
  21865. /**
  21866. * @hidden
  21867. * Specifies if the material was previously ready
  21868. */ wasPreviouslyReady: boolean;
  21869. /**
  21870. * Specifies if uniform buffers should be used
  21871. */
  21872. private _useUBO;
  21873. /**
  21874. * Stores a reference to the scene
  21875. */
  21876. private _scene;
  21877. /**
  21878. * Stores the fill mode state
  21879. */
  21880. private _fillMode;
  21881. /**
  21882. * Specifies if the depth write state should be cached
  21883. */
  21884. private _cachedDepthWriteState;
  21885. /**
  21886. * Stores the uniform buffer
  21887. */
  21888. protected _uniformBuffer: UniformBuffer;
  21889. /** @hidden */ indexInSceneMaterialArray: number;
  21890. /** @hidden */
  21891. meshMap: Nullable<{
  21892. [id: string]: AbstractMesh | undefined;
  21893. }>;
  21894. /**
  21895. * Creates a material instance
  21896. * @param name defines the name of the material
  21897. * @param scene defines the scene to reference
  21898. * @param doNotAdd specifies if the material should be added to the scene
  21899. */
  21900. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21901. /**
  21902. * Returns a string representation of the current material
  21903. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21904. * @returns a string with material information
  21905. */
  21906. toString(fullDetails?: boolean): string;
  21907. /**
  21908. * Gets the class name of the material
  21909. * @returns a string with the class name of the material
  21910. */
  21911. getClassName(): string;
  21912. /**
  21913. * Specifies if updates for the material been locked
  21914. */
  21915. readonly isFrozen: boolean;
  21916. /**
  21917. * Locks updates for the material
  21918. */
  21919. freeze(): void;
  21920. /**
  21921. * Unlocks updates for the material
  21922. */
  21923. unfreeze(): void;
  21924. /**
  21925. * Specifies if the material is ready to be used
  21926. * @param mesh defines the mesh to check
  21927. * @param useInstances specifies if instances should be used
  21928. * @returns a boolean indicating if the material is ready to be used
  21929. */
  21930. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21931. /**
  21932. * Specifies that the submesh is ready to be used
  21933. * @param mesh defines the mesh to check
  21934. * @param subMesh defines which submesh to check
  21935. * @param useInstances specifies that instances should be used
  21936. * @returns a boolean indicating that the submesh is ready or not
  21937. */
  21938. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21939. /**
  21940. * Returns the material effect
  21941. * @returns the effect associated with the material
  21942. */
  21943. getEffect(): Nullable<Effect>;
  21944. /**
  21945. * Returns the current scene
  21946. * @returns a Scene
  21947. */
  21948. getScene(): Scene;
  21949. /**
  21950. * Specifies if the material will require alpha blending
  21951. * @returns a boolean specifying if alpha blending is needed
  21952. */
  21953. needAlphaBlending(): boolean;
  21954. /**
  21955. * Specifies if the mesh will require alpha blending
  21956. * @param mesh defines the mesh to check
  21957. * @returns a boolean specifying if alpha blending is needed for the mesh
  21958. */
  21959. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21960. /**
  21961. * Specifies if this material should be rendered in alpha test mode
  21962. * @returns a boolean specifying if an alpha test is needed.
  21963. */
  21964. needAlphaTesting(): boolean;
  21965. /**
  21966. * Gets the texture used for the alpha test
  21967. * @returns the texture to use for alpha testing
  21968. */
  21969. getAlphaTestTexture(): Nullable<BaseTexture>;
  21970. /**
  21971. * Marks the material to indicate that it needs to be re-calculated
  21972. */
  21973. markDirty(): void;
  21974. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21975. /**
  21976. * Binds the material to the mesh
  21977. * @param world defines the world transformation matrix
  21978. * @param mesh defines the mesh to bind the material to
  21979. */
  21980. bind(world: Matrix, mesh?: Mesh): void;
  21981. /**
  21982. * Binds the submesh to the material
  21983. * @param world defines the world transformation matrix
  21984. * @param mesh defines the mesh containing the submesh
  21985. * @param subMesh defines the submesh to bind the material to
  21986. */
  21987. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21988. /**
  21989. * Binds the world matrix to the material
  21990. * @param world defines the world transformation matrix
  21991. */
  21992. bindOnlyWorldMatrix(world: Matrix): void;
  21993. /**
  21994. * Binds the scene's uniform buffer to the effect.
  21995. * @param effect defines the effect to bind to the scene uniform buffer
  21996. * @param sceneUbo defines the uniform buffer storing scene data
  21997. */
  21998. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21999. /**
  22000. * Binds the view matrix to the effect
  22001. * @param effect defines the effect to bind the view matrix to
  22002. */
  22003. bindView(effect: Effect): void;
  22004. /**
  22005. * Binds the view projection matrix to the effect
  22006. * @param effect defines the effect to bind the view projection matrix to
  22007. */
  22008. bindViewProjection(effect: Effect): void;
  22009. /**
  22010. * Specifies if material alpha testing should be turned on for the mesh
  22011. * @param mesh defines the mesh to check
  22012. */
  22013. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22014. /**
  22015. * Processes to execute after binding the material to a mesh
  22016. * @param mesh defines the rendered mesh
  22017. */
  22018. protected _afterBind(mesh?: Mesh): void;
  22019. /**
  22020. * Unbinds the material from the mesh
  22021. */
  22022. unbind(): void;
  22023. /**
  22024. * Gets the active textures from the material
  22025. * @returns an array of textures
  22026. */
  22027. getActiveTextures(): BaseTexture[];
  22028. /**
  22029. * Specifies if the material uses a texture
  22030. * @param texture defines the texture to check against the material
  22031. * @returns a boolean specifying if the material uses the texture
  22032. */
  22033. hasTexture(texture: BaseTexture): boolean;
  22034. /**
  22035. * Makes a duplicate of the material, and gives it a new name
  22036. * @param name defines the new name for the duplicated material
  22037. * @returns the cloned material
  22038. */
  22039. clone(name: string): Nullable<Material>;
  22040. /**
  22041. * Gets the meshes bound to the material
  22042. * @returns an array of meshes bound to the material
  22043. */
  22044. getBindedMeshes(): AbstractMesh[];
  22045. /**
  22046. * Force shader compilation
  22047. * @param mesh defines the mesh associated with this material
  22048. * @param onCompiled defines a function to execute once the material is compiled
  22049. * @param options defines the options to configure the compilation
  22050. */
  22051. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22052. clipPlane: boolean;
  22053. }>): void;
  22054. /**
  22055. * Force shader compilation
  22056. * @param mesh defines the mesh that will use this material
  22057. * @param options defines additional options for compiling the shaders
  22058. * @returns a promise that resolves when the compilation completes
  22059. */
  22060. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22061. clipPlane: boolean;
  22062. }>): Promise<void>;
  22063. private static readonly _ImageProcessingDirtyCallBack;
  22064. private static readonly _TextureDirtyCallBack;
  22065. private static readonly _FresnelDirtyCallBack;
  22066. private static readonly _MiscDirtyCallBack;
  22067. private static readonly _LightsDirtyCallBack;
  22068. private static readonly _AttributeDirtyCallBack;
  22069. private static _FresnelAndMiscDirtyCallBack;
  22070. private static _TextureAndMiscDirtyCallBack;
  22071. private static readonly _DirtyCallbackArray;
  22072. private static readonly _RunDirtyCallBacks;
  22073. /**
  22074. * Marks a define in the material to indicate that it needs to be re-computed
  22075. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22076. */
  22077. markAsDirty(flag: number): void;
  22078. /**
  22079. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22080. * @param func defines a function which checks material defines against the submeshes
  22081. */
  22082. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22083. /**
  22084. * Indicates that image processing needs to be re-calculated for all submeshes
  22085. */
  22086. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22087. /**
  22088. * Indicates that textures need to be re-calculated for all submeshes
  22089. */
  22090. protected _markAllSubMeshesAsTexturesDirty(): void;
  22091. /**
  22092. * Indicates that fresnel needs to be re-calculated for all submeshes
  22093. */
  22094. protected _markAllSubMeshesAsFresnelDirty(): void;
  22095. /**
  22096. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22097. */
  22098. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22099. /**
  22100. * Indicates that lights need to be re-calculated for all submeshes
  22101. */
  22102. protected _markAllSubMeshesAsLightsDirty(): void;
  22103. /**
  22104. * Indicates that attributes need to be re-calculated for all submeshes
  22105. */
  22106. protected _markAllSubMeshesAsAttributesDirty(): void;
  22107. /**
  22108. * Indicates that misc needs to be re-calculated for all submeshes
  22109. */
  22110. protected _markAllSubMeshesAsMiscDirty(): void;
  22111. /**
  22112. * Indicates that textures and misc need to be re-calculated for all submeshes
  22113. */
  22114. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22115. /**
  22116. * Disposes the material
  22117. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22118. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22119. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22120. */
  22121. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22122. /** @hidden */
  22123. private releaseVertexArrayObject;
  22124. /**
  22125. * Serializes this material
  22126. * @returns the serialized material object
  22127. */
  22128. serialize(): any;
  22129. /**
  22130. * Creates a material from parsed material data
  22131. * @param parsedMaterial defines parsed material data
  22132. * @param scene defines the hosting scene
  22133. * @param rootUrl defines the root URL to use to load textures
  22134. * @returns a new material
  22135. */
  22136. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22137. }
  22138. }
  22139. declare module BABYLON {
  22140. /**
  22141. * Base class for submeshes
  22142. */
  22143. export class BaseSubMesh {
  22144. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  22145. /** @hidden */ materialEffect: Nullable<Effect>;
  22146. /**
  22147. * Gets associated effect
  22148. */
  22149. readonly effect: Nullable<Effect>;
  22150. /**
  22151. * Sets associated effect (effect used to render this submesh)
  22152. * @param effect defines the effect to associate with
  22153. * @param defines defines the set of defines used to compile this effect
  22154. */
  22155. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22156. }
  22157. /**
  22158. * Defines a subdivision inside a mesh
  22159. */
  22160. export class SubMesh extends BaseSubMesh implements ICullable {
  22161. /** the material index to use */
  22162. materialIndex: number;
  22163. /** vertex index start */
  22164. verticesStart: number;
  22165. /** vertices count */
  22166. verticesCount: number;
  22167. /** index start */
  22168. indexStart: number;
  22169. /** indices count */
  22170. indexCount: number;
  22171. /** @hidden */ linesIndexCount: number;
  22172. private _mesh;
  22173. private _renderingMesh;
  22174. private _boundingInfo;
  22175. private _linesIndexBuffer;
  22176. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  22177. /** @hidden */ trianglePlanes: Plane[];
  22178. /** @hidden */ lastColliderTransformMatrix: Nullable<Matrix>;
  22179. /** @hidden */ renderId: number;
  22180. /** @hidden */ alphaIndex: number;
  22181. /** @hidden */ distanceToCamera: number;
  22182. /** @hidden */ id: number;
  22183. private _currentMaterial;
  22184. /**
  22185. * Add a new submesh to a mesh
  22186. * @param materialIndex defines the material index to use
  22187. * @param verticesStart defines vertex index start
  22188. * @param verticesCount defines vertices count
  22189. * @param indexStart defines index start
  22190. * @param indexCount defines indices count
  22191. * @param mesh defines the parent mesh
  22192. * @param renderingMesh defines an optional rendering mesh
  22193. * @param createBoundingBox defines if bounding box should be created for this submesh
  22194. * @returns the new submesh
  22195. */
  22196. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22197. /**
  22198. * Creates a new submesh
  22199. * @param materialIndex defines the material index to use
  22200. * @param verticesStart defines vertex index start
  22201. * @param verticesCount defines vertices count
  22202. * @param indexStart defines index start
  22203. * @param indexCount defines indices count
  22204. * @param mesh defines the parent mesh
  22205. * @param renderingMesh defines an optional rendering mesh
  22206. * @param createBoundingBox defines if bounding box should be created for this submesh
  22207. */
  22208. constructor(
  22209. /** the material index to use */
  22210. materialIndex: number,
  22211. /** vertex index start */
  22212. verticesStart: number,
  22213. /** vertices count */
  22214. verticesCount: number,
  22215. /** index start */
  22216. indexStart: number,
  22217. /** indices count */
  22218. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22219. /**
  22220. * Returns true if this submesh covers the entire parent mesh
  22221. * @ignorenaming
  22222. */
  22223. readonly IsGlobal: boolean;
  22224. /**
  22225. * Returns the submesh BoudingInfo object
  22226. * @returns current bounding info (or mesh's one if the submesh is global)
  22227. */
  22228. getBoundingInfo(): BoundingInfo;
  22229. /**
  22230. * Sets the submesh BoundingInfo
  22231. * @param boundingInfo defines the new bounding info to use
  22232. * @returns the SubMesh
  22233. */
  22234. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22235. /**
  22236. * Returns the mesh of the current submesh
  22237. * @return the parent mesh
  22238. */
  22239. getMesh(): AbstractMesh;
  22240. /**
  22241. * Returns the rendering mesh of the submesh
  22242. * @returns the rendering mesh (could be different from parent mesh)
  22243. */
  22244. getRenderingMesh(): Mesh;
  22245. /**
  22246. * Returns the submesh material
  22247. * @returns null or the current material
  22248. */
  22249. getMaterial(): Nullable<Material>;
  22250. /**
  22251. * Sets a new updated BoundingInfo object to the submesh
  22252. * @param data defines an optional position array to use to determine the bounding info
  22253. * @returns the SubMesh
  22254. */
  22255. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22256. /** @hidden */ checkCollision(collider: Collider): boolean;
  22257. /**
  22258. * Updates the submesh BoundingInfo
  22259. * @param world defines the world matrix to use to update the bounding info
  22260. * @returns the submesh
  22261. */
  22262. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22263. /**
  22264. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22265. * @param frustumPlanes defines the frustum planes
  22266. * @returns true if the submesh is intersecting with the frustum
  22267. */
  22268. isInFrustum(frustumPlanes: Plane[]): boolean;
  22269. /**
  22270. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22271. * @param frustumPlanes defines the frustum planes
  22272. * @returns true if the submesh is inside the frustum
  22273. */
  22274. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22275. /**
  22276. * Renders the submesh
  22277. * @param enableAlphaMode defines if alpha needs to be used
  22278. * @returns the submesh
  22279. */
  22280. render(enableAlphaMode: boolean): SubMesh;
  22281. /**
  22282. * @hidden
  22283. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22284. /**
  22285. * Checks if the submesh intersects with a ray
  22286. * @param ray defines the ray to test
  22287. * @returns true is the passed ray intersects the submesh bounding box
  22288. */
  22289. canIntersects(ray: Ray): boolean;
  22290. /**
  22291. * Intersects current submesh with a ray
  22292. * @param ray defines the ray to test
  22293. * @param positions defines mesh's positions array
  22294. * @param indices defines mesh's indices array
  22295. * @param fastCheck defines if only bounding info should be used
  22296. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22297. * @returns intersection info or null if no intersection
  22298. */
  22299. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22300. /** @hidden */
  22301. private _intersectLines;
  22302. /** @hidden */
  22303. private _intersectTriangles;
  22304. /** @hidden */ rebuild(): void;
  22305. /**
  22306. * Creates a new submesh from the passed mesh
  22307. * @param newMesh defines the new hosting mesh
  22308. * @param newRenderingMesh defines an optional rendering mesh
  22309. * @returns the new submesh
  22310. */
  22311. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22312. /**
  22313. * Release associated resources
  22314. */
  22315. dispose(): void;
  22316. /**
  22317. * Gets the class name
  22318. * @returns the string "SubMesh".
  22319. */
  22320. getClassName(): string;
  22321. /**
  22322. * Creates a new submesh from indices data
  22323. * @param materialIndex the index of the main mesh material
  22324. * @param startIndex the index where to start the copy in the mesh indices array
  22325. * @param indexCount the number of indices to copy then from the startIndex
  22326. * @param mesh the main mesh to create the submesh from
  22327. * @param renderingMesh the optional rendering mesh
  22328. * @returns a new submesh
  22329. */
  22330. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22331. }
  22332. }
  22333. declare module BABYLON {
  22334. /**
  22335. * Class used to store geometry data (vertex buffers + index buffer)
  22336. */
  22337. export class Geometry implements IGetSetVerticesData {
  22338. /**
  22339. * Gets or sets the ID of the geometry
  22340. */
  22341. id: string;
  22342. /**
  22343. * Gets or sets the unique ID of the geometry
  22344. */
  22345. uniqueId: number;
  22346. /**
  22347. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22348. */
  22349. delayLoadState: number;
  22350. /**
  22351. * Gets the file containing the data to load when running in delay load state
  22352. */
  22353. delayLoadingFile: Nullable<string>;
  22354. /**
  22355. * Callback called when the geometry is updated
  22356. */
  22357. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22358. private _scene;
  22359. private _engine;
  22360. private _meshes;
  22361. private _totalVertices;
  22362. /** @hidden */ indices: IndicesArray;
  22363. /** @hidden */ vertexBuffers: {
  22364. [key: string]: VertexBuffer;
  22365. };
  22366. private _isDisposed;
  22367. private _extend;
  22368. private _boundingBias;
  22369. /** @hidden */ delayInfo: Array<string>;
  22370. private _indexBuffer;
  22371. private _indexBufferIsUpdatable;
  22372. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  22373. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22374. /** @hidden */ softwareSkinningFrameId: number;
  22375. private _vertexArrayObjects;
  22376. private _updatable;
  22377. /** @hidden */ positions: Nullable<Vector3[]>;
  22378. /**
  22379. * 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
  22380. */
  22381. /**
  22382. * 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
  22383. */
  22384. boundingBias: Vector2;
  22385. /**
  22386. * Static function used to attach a new empty geometry to a mesh
  22387. * @param mesh defines the mesh to attach the geometry to
  22388. * @returns the new Geometry
  22389. */
  22390. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22391. /**
  22392. * Creates a new geometry
  22393. * @param id defines the unique ID
  22394. * @param scene defines the hosting scene
  22395. * @param vertexData defines the VertexData used to get geometry data
  22396. * @param updatable defines if geometry must be updatable (false by default)
  22397. * @param mesh defines the mesh that will be associated with the geometry
  22398. */
  22399. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22400. /**
  22401. * Gets the current extend of the geometry
  22402. */
  22403. readonly extend: {
  22404. minimum: Vector3;
  22405. maximum: Vector3;
  22406. };
  22407. /**
  22408. * Gets the hosting scene
  22409. * @returns the hosting Scene
  22410. */
  22411. getScene(): Scene;
  22412. /**
  22413. * Gets the hosting engine
  22414. * @returns the hosting Engine
  22415. */
  22416. getEngine(): Engine;
  22417. /**
  22418. * Defines if the geometry is ready to use
  22419. * @returns true if the geometry is ready to be used
  22420. */
  22421. isReady(): boolean;
  22422. /**
  22423. * Gets a value indicating that the geometry should not be serialized
  22424. */
  22425. readonly doNotSerialize: boolean;
  22426. /** @hidden */ rebuild(): void;
  22427. /**
  22428. * Affects all geometry data in one call
  22429. * @param vertexData defines the geometry data
  22430. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22431. */
  22432. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22433. /**
  22434. * Set specific vertex data
  22435. * @param kind defines the data kind (Position, normal, etc...)
  22436. * @param data defines the vertex data to use
  22437. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22438. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22439. */
  22440. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22441. /**
  22442. * Removes a specific vertex data
  22443. * @param kind defines the data kind (Position, normal, etc...)
  22444. */
  22445. removeVerticesData(kind: string): void;
  22446. /**
  22447. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22448. * @param buffer defines the vertex buffer to use
  22449. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22450. */
  22451. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22452. /**
  22453. * Update a specific vertex buffer
  22454. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22455. * It will do nothing if the buffer is not updatable
  22456. * @param kind defines the data kind (Position, normal, etc...)
  22457. * @param data defines the data to use
  22458. * @param offset defines the offset in the target buffer where to store the data
  22459. * @param useBytes set to true if the offset is in bytes
  22460. */
  22461. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22462. /**
  22463. * Update a specific vertex buffer
  22464. * This function will create a new buffer if the current one is not updatable
  22465. * @param kind defines the data kind (Position, normal, etc...)
  22466. * @param data defines the data to use
  22467. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22468. */
  22469. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22470. private _updateBoundingInfo;
  22471. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22472. /**
  22473. * Gets total number of vertices
  22474. * @returns the total number of vertices
  22475. */
  22476. getTotalVertices(): number;
  22477. /**
  22478. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22479. * @param kind defines the data kind (Position, normal, etc...)
  22480. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22481. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22482. * @returns a float array containing vertex data
  22483. */
  22484. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22485. /**
  22486. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22487. * @param kind defines the data kind (Position, normal, etc...)
  22488. * @returns true if the vertex buffer with the specified kind is updatable
  22489. */
  22490. isVertexBufferUpdatable(kind: string): boolean;
  22491. /**
  22492. * Gets a specific vertex buffer
  22493. * @param kind defines the data kind (Position, normal, etc...)
  22494. * @returns a VertexBuffer
  22495. */
  22496. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22497. /**
  22498. * Returns all vertex buffers
  22499. * @return an object holding all vertex buffers indexed by kind
  22500. */
  22501. getVertexBuffers(): Nullable<{
  22502. [key: string]: VertexBuffer;
  22503. }>;
  22504. /**
  22505. * Gets a boolean indicating if specific vertex buffer is present
  22506. * @param kind defines the data kind (Position, normal, etc...)
  22507. * @returns true if data is present
  22508. */
  22509. isVerticesDataPresent(kind: string): boolean;
  22510. /**
  22511. * Gets a list of all attached data kinds (Position, normal, etc...)
  22512. * @returns a list of string containing all kinds
  22513. */
  22514. getVerticesDataKinds(): string[];
  22515. /**
  22516. * Update index buffer
  22517. * @param indices defines the indices to store in the index buffer
  22518. * @param offset defines the offset in the target buffer where to store the data
  22519. * @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)
  22520. */
  22521. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22522. /**
  22523. * Creates a new index buffer
  22524. * @param indices defines the indices to store in the index buffer
  22525. * @param totalVertices defines the total number of vertices (could be null)
  22526. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22527. */
  22528. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22529. /**
  22530. * Return the total number of indices
  22531. * @returns the total number of indices
  22532. */
  22533. getTotalIndices(): number;
  22534. /**
  22535. * Gets the index buffer array
  22536. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22537. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22538. * @returns the index buffer array
  22539. */
  22540. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22541. /**
  22542. * Gets the index buffer
  22543. * @return the index buffer
  22544. */
  22545. getIndexBuffer(): Nullable<DataBuffer>;
  22546. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22547. /**
  22548. * Release the associated resources for a specific mesh
  22549. * @param mesh defines the source mesh
  22550. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22551. */
  22552. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22553. /**
  22554. * Apply current geometry to a given mesh
  22555. * @param mesh defines the mesh to apply geometry to
  22556. */
  22557. applyToMesh(mesh: Mesh): void;
  22558. private _updateExtend;
  22559. private _applyToMesh;
  22560. private notifyUpdate;
  22561. /**
  22562. * Load the geometry if it was flagged as delay loaded
  22563. * @param scene defines the hosting scene
  22564. * @param onLoaded defines a callback called when the geometry is loaded
  22565. */
  22566. load(scene: Scene, onLoaded?: () => void): void;
  22567. private _queueLoad;
  22568. /**
  22569. * Invert the geometry to move from a right handed system to a left handed one.
  22570. */
  22571. toLeftHanded(): void;
  22572. /** @hidden */ resetPointsArrayCache(): void;
  22573. /** @hidden */ generatePointsArray(): boolean;
  22574. /**
  22575. * Gets a value indicating if the geometry is disposed
  22576. * @returns true if the geometry was disposed
  22577. */
  22578. isDisposed(): boolean;
  22579. private _disposeVertexArrayObjects;
  22580. /**
  22581. * Free all associated resources
  22582. */
  22583. dispose(): void;
  22584. /**
  22585. * Clone the current geometry into a new geometry
  22586. * @param id defines the unique ID of the new geometry
  22587. * @returns a new geometry object
  22588. */
  22589. copy(id: string): Geometry;
  22590. /**
  22591. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22592. * @return a JSON representation of the current geometry data (without the vertices data)
  22593. */
  22594. serialize(): any;
  22595. private toNumberArray;
  22596. /**
  22597. * Serialize all vertices data into a JSON oject
  22598. * @returns a JSON representation of the current geometry data
  22599. */
  22600. serializeVerticeData(): any;
  22601. /**
  22602. * Extracts a clone of a mesh geometry
  22603. * @param mesh defines the source mesh
  22604. * @param id defines the unique ID of the new geometry object
  22605. * @returns the new geometry object
  22606. */
  22607. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22608. /**
  22609. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22610. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22611. * Be aware Math.random() could cause collisions, but:
  22612. * "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"
  22613. * @returns a string containing a new GUID
  22614. */
  22615. static RandomId(): string;
  22616. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22617. private static _CleanMatricesWeights;
  22618. /**
  22619. * Create a new geometry from persisted data (Using .babylon file format)
  22620. * @param parsedVertexData defines the persisted data
  22621. * @param scene defines the hosting scene
  22622. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22623. * @returns the new geometry object
  22624. */
  22625. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22626. }
  22627. }
  22628. declare module BABYLON {
  22629. /**
  22630. * Define an interface for all classes that will get and set the data on vertices
  22631. */
  22632. export interface IGetSetVerticesData {
  22633. /**
  22634. * Gets a boolean indicating if specific vertex data is present
  22635. * @param kind defines the vertex data kind to use
  22636. * @returns true is data kind is present
  22637. */
  22638. isVerticesDataPresent(kind: string): boolean;
  22639. /**
  22640. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22641. * @param kind defines the data kind (Position, normal, etc...)
  22642. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22643. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22644. * @returns a float array containing vertex data
  22645. */
  22646. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22647. /**
  22648. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22649. * @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.
  22650. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22651. * @returns the indices array or an empty array if the mesh has no geometry
  22652. */
  22653. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22654. /**
  22655. * Set specific vertex data
  22656. * @param kind defines the data kind (Position, normal, etc...)
  22657. * @param data defines the vertex data to use
  22658. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22659. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22660. */
  22661. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22662. /**
  22663. * Update a specific associated vertex buffer
  22664. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22665. * - VertexBuffer.PositionKind
  22666. * - VertexBuffer.UVKind
  22667. * - VertexBuffer.UV2Kind
  22668. * - VertexBuffer.UV3Kind
  22669. * - VertexBuffer.UV4Kind
  22670. * - VertexBuffer.UV5Kind
  22671. * - VertexBuffer.UV6Kind
  22672. * - VertexBuffer.ColorKind
  22673. * - VertexBuffer.MatricesIndicesKind
  22674. * - VertexBuffer.MatricesIndicesExtraKind
  22675. * - VertexBuffer.MatricesWeightsKind
  22676. * - VertexBuffer.MatricesWeightsExtraKind
  22677. * @param data defines the data source
  22678. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22679. * @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)
  22680. */
  22681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22682. /**
  22683. * Creates a new index buffer
  22684. * @param indices defines the indices to store in the index buffer
  22685. * @param totalVertices defines the total number of vertices (could be null)
  22686. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22687. */
  22688. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22689. }
  22690. /**
  22691. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22692. */
  22693. export class VertexData {
  22694. /**
  22695. * Mesh side orientation : usually the external or front surface
  22696. */
  22697. static readonly FRONTSIDE: number;
  22698. /**
  22699. * Mesh side orientation : usually the internal or back surface
  22700. */
  22701. static readonly BACKSIDE: number;
  22702. /**
  22703. * Mesh side orientation : both internal and external or front and back surfaces
  22704. */
  22705. static readonly DOUBLESIDE: number;
  22706. /**
  22707. * Mesh side orientation : by default, `FRONTSIDE`
  22708. */
  22709. static readonly DEFAULTSIDE: number;
  22710. /**
  22711. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22712. */
  22713. positions: Nullable<FloatArray>;
  22714. /**
  22715. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22716. */
  22717. normals: Nullable<FloatArray>;
  22718. /**
  22719. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22720. */
  22721. tangents: Nullable<FloatArray>;
  22722. /**
  22723. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22724. */
  22725. uvs: Nullable<FloatArray>;
  22726. /**
  22727. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22728. */
  22729. uvs2: Nullable<FloatArray>;
  22730. /**
  22731. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22732. */
  22733. uvs3: Nullable<FloatArray>;
  22734. /**
  22735. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22736. */
  22737. uvs4: Nullable<FloatArray>;
  22738. /**
  22739. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22740. */
  22741. uvs5: Nullable<FloatArray>;
  22742. /**
  22743. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22744. */
  22745. uvs6: Nullable<FloatArray>;
  22746. /**
  22747. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22748. */
  22749. colors: Nullable<FloatArray>;
  22750. /**
  22751. * 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).
  22752. */
  22753. matricesIndices: Nullable<FloatArray>;
  22754. /**
  22755. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22756. */
  22757. matricesWeights: Nullable<FloatArray>;
  22758. /**
  22759. * An array extending the number of possible indices
  22760. */
  22761. matricesIndicesExtra: Nullable<FloatArray>;
  22762. /**
  22763. * An array extending the number of possible weights when the number of indices is extended
  22764. */
  22765. matricesWeightsExtra: Nullable<FloatArray>;
  22766. /**
  22767. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22768. */
  22769. indices: Nullable<IndicesArray>;
  22770. /**
  22771. * Uses the passed data array to set the set the values for the specified kind of data
  22772. * @param data a linear array of floating numbers
  22773. * @param kind the type of data that is being set, eg positions, colors etc
  22774. */
  22775. set(data: FloatArray, kind: string): void;
  22776. /**
  22777. * Associates the vertexData to the passed Mesh.
  22778. * Sets it as updatable or not (default `false`)
  22779. * @param mesh the mesh the vertexData is applied to
  22780. * @param updatable when used and having the value true allows new data to update the vertexData
  22781. * @returns the VertexData
  22782. */
  22783. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22784. /**
  22785. * Associates the vertexData to the passed Geometry.
  22786. * Sets it as updatable or not (default `false`)
  22787. * @param geometry the geometry the vertexData is applied to
  22788. * @param updatable when used and having the value true allows new data to update the vertexData
  22789. * @returns VertexData
  22790. */
  22791. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22792. /**
  22793. * Updates the associated mesh
  22794. * @param mesh the mesh to be updated
  22795. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22796. * @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
  22797. * @returns VertexData
  22798. */
  22799. updateMesh(mesh: Mesh): VertexData;
  22800. /**
  22801. * Updates the associated geometry
  22802. * @param geometry the geometry to be updated
  22803. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22804. * @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
  22805. * @returns VertexData.
  22806. */
  22807. updateGeometry(geometry: Geometry): VertexData;
  22808. private _applyTo;
  22809. private _update;
  22810. /**
  22811. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22812. * @param matrix the transforming matrix
  22813. * @returns the VertexData
  22814. */
  22815. transform(matrix: Matrix): VertexData;
  22816. /**
  22817. * Merges the passed VertexData into the current one
  22818. * @param other the VertexData to be merged into the current one
  22819. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22820. * @returns the modified VertexData
  22821. */
  22822. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22823. private _mergeElement;
  22824. private _validate;
  22825. /**
  22826. * Serializes the VertexData
  22827. * @returns a serialized object
  22828. */
  22829. serialize(): any;
  22830. /**
  22831. * Extracts the vertexData from a mesh
  22832. * @param mesh the mesh from which to extract the VertexData
  22833. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22834. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22835. * @returns the object VertexData associated to the passed mesh
  22836. */
  22837. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22838. /**
  22839. * Extracts the vertexData from the geometry
  22840. * @param geometry the geometry from which to extract the VertexData
  22841. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22842. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22843. * @returns the object VertexData associated to the passed mesh
  22844. */
  22845. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22846. private static _ExtractFrom;
  22847. /**
  22848. * Creates the VertexData for a Ribbon
  22849. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22850. * * pathArray array of paths, each of which an array of successive Vector3
  22851. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22852. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22853. * * 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
  22854. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22855. * * 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)
  22856. * * 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)
  22857. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22858. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22859. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22860. * @returns the VertexData of the ribbon
  22861. */
  22862. static CreateRibbon(options: {
  22863. pathArray: Vector3[][];
  22864. closeArray?: boolean;
  22865. closePath?: boolean;
  22866. offset?: number;
  22867. sideOrientation?: number;
  22868. frontUVs?: Vector4;
  22869. backUVs?: Vector4;
  22870. invertUV?: boolean;
  22871. uvs?: Vector2[];
  22872. colors?: Color4[];
  22873. }): VertexData;
  22874. /**
  22875. * Creates the VertexData for a box
  22876. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22877. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22878. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22879. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22880. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22881. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22882. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22883. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22884. * * 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)
  22885. * * 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)
  22886. * @returns the VertexData of the box
  22887. */
  22888. static CreateBox(options: {
  22889. size?: number;
  22890. width?: number;
  22891. height?: number;
  22892. depth?: number;
  22893. faceUV?: Vector4[];
  22894. faceColors?: Color4[];
  22895. sideOrientation?: number;
  22896. frontUVs?: Vector4;
  22897. backUVs?: Vector4;
  22898. }): VertexData;
  22899. /**
  22900. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22901. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22902. * * segments sets the number of horizontal strips optional, default 32
  22903. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22904. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22905. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22906. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22907. * * 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
  22908. * * 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
  22909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22910. * * 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)
  22911. * * 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)
  22912. * @returns the VertexData of the ellipsoid
  22913. */
  22914. static CreateSphere(options: {
  22915. segments?: number;
  22916. diameter?: number;
  22917. diameterX?: number;
  22918. diameterY?: number;
  22919. diameterZ?: number;
  22920. arc?: number;
  22921. slice?: number;
  22922. sideOrientation?: number;
  22923. frontUVs?: Vector4;
  22924. backUVs?: Vector4;
  22925. }): VertexData;
  22926. /**
  22927. * Creates the VertexData for a cylinder, cone or prism
  22928. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22929. * * height sets the height (y direction) of the cylinder, optional, default 2
  22930. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22931. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22932. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22933. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22934. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22935. * * 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
  22936. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22937. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22938. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22939. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22940. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22941. * * 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)
  22942. * * 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)
  22943. * @returns the VertexData of the cylinder, cone or prism
  22944. */
  22945. static CreateCylinder(options: {
  22946. height?: number;
  22947. diameterTop?: number;
  22948. diameterBottom?: number;
  22949. diameter?: number;
  22950. tessellation?: number;
  22951. subdivisions?: number;
  22952. arc?: number;
  22953. faceColors?: Color4[];
  22954. faceUV?: Vector4[];
  22955. hasRings?: boolean;
  22956. enclose?: boolean;
  22957. sideOrientation?: number;
  22958. frontUVs?: Vector4;
  22959. backUVs?: Vector4;
  22960. }): VertexData;
  22961. /**
  22962. * Creates the VertexData for a torus
  22963. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22964. * * diameter the diameter of the torus, optional default 1
  22965. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22966. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22968. * * 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)
  22969. * * 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)
  22970. * @returns the VertexData of the torus
  22971. */
  22972. static CreateTorus(options: {
  22973. diameter?: number;
  22974. thickness?: number;
  22975. tessellation?: number;
  22976. sideOrientation?: number;
  22977. frontUVs?: Vector4;
  22978. backUVs?: Vector4;
  22979. }): VertexData;
  22980. /**
  22981. * Creates the VertexData of the LineSystem
  22982. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22983. * - lines an array of lines, each line being an array of successive Vector3
  22984. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22985. * @returns the VertexData of the LineSystem
  22986. */
  22987. static CreateLineSystem(options: {
  22988. lines: Vector3[][];
  22989. colors?: Nullable<Color4[][]>;
  22990. }): VertexData;
  22991. /**
  22992. * Create the VertexData for a DashedLines
  22993. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22994. * - points an array successive Vector3
  22995. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22996. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22997. * - dashNb the intended total number of dashes, optional, default 200
  22998. * @returns the VertexData for the DashedLines
  22999. */
  23000. static CreateDashedLines(options: {
  23001. points: Vector3[];
  23002. dashSize?: number;
  23003. gapSize?: number;
  23004. dashNb?: number;
  23005. }): VertexData;
  23006. /**
  23007. * Creates the VertexData for a Ground
  23008. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23009. * - width the width (x direction) of the ground, optional, default 1
  23010. * - height the height (z direction) of the ground, optional, default 1
  23011. * - subdivisions the number of subdivisions per side, optional, default 1
  23012. * @returns the VertexData of the Ground
  23013. */
  23014. static CreateGround(options: {
  23015. width?: number;
  23016. height?: number;
  23017. subdivisions?: number;
  23018. subdivisionsX?: number;
  23019. subdivisionsY?: number;
  23020. }): VertexData;
  23021. /**
  23022. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23023. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23024. * * xmin the ground minimum X coordinate, optional, default -1
  23025. * * zmin the ground minimum Z coordinate, optional, default -1
  23026. * * xmax the ground maximum X coordinate, optional, default 1
  23027. * * zmax the ground maximum Z coordinate, optional, default 1
  23028. * * 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}
  23029. * * 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}
  23030. * @returns the VertexData of the TiledGround
  23031. */
  23032. static CreateTiledGround(options: {
  23033. xmin: number;
  23034. zmin: number;
  23035. xmax: number;
  23036. zmax: number;
  23037. subdivisions?: {
  23038. w: number;
  23039. h: number;
  23040. };
  23041. precision?: {
  23042. w: number;
  23043. h: number;
  23044. };
  23045. }): VertexData;
  23046. /**
  23047. * Creates the VertexData of the Ground designed from a heightmap
  23048. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23049. * * width the width (x direction) of the ground
  23050. * * height the height (z direction) of the ground
  23051. * * subdivisions the number of subdivisions per side
  23052. * * minHeight the minimum altitude on the ground, optional, default 0
  23053. * * maxHeight the maximum altitude on the ground, optional default 1
  23054. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23055. * * buffer the array holding the image color data
  23056. * * bufferWidth the width of image
  23057. * * bufferHeight the height of image
  23058. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23059. * @returns the VertexData of the Ground designed from a heightmap
  23060. */
  23061. static CreateGroundFromHeightMap(options: {
  23062. width: number;
  23063. height: number;
  23064. subdivisions: number;
  23065. minHeight: number;
  23066. maxHeight: number;
  23067. colorFilter: Color3;
  23068. buffer: Uint8Array;
  23069. bufferWidth: number;
  23070. bufferHeight: number;
  23071. alphaFilter: number;
  23072. }): VertexData;
  23073. /**
  23074. * Creates the VertexData for a Plane
  23075. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23076. * * size sets the width and height of the plane to the value of size, optional default 1
  23077. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23078. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23079. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23080. * * 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)
  23081. * * 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)
  23082. * @returns the VertexData of the box
  23083. */
  23084. static CreatePlane(options: {
  23085. size?: number;
  23086. width?: number;
  23087. height?: number;
  23088. sideOrientation?: number;
  23089. frontUVs?: Vector4;
  23090. backUVs?: Vector4;
  23091. }): VertexData;
  23092. /**
  23093. * Creates the VertexData of the Disc or regular Polygon
  23094. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23095. * * radius the radius of the disc, optional default 0.5
  23096. * * tessellation the number of polygon sides, optional, default 64
  23097. * * 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
  23098. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23099. * * 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)
  23100. * * 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)
  23101. * @returns the VertexData of the box
  23102. */
  23103. static CreateDisc(options: {
  23104. radius?: number;
  23105. tessellation?: number;
  23106. arc?: number;
  23107. sideOrientation?: number;
  23108. frontUVs?: Vector4;
  23109. backUVs?: Vector4;
  23110. }): VertexData;
  23111. /**
  23112. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23113. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23114. * @param polygon a mesh built from polygonTriangulation.build()
  23115. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23116. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23117. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23118. * @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)
  23119. * @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)
  23120. * @returns the VertexData of the Polygon
  23121. */
  23122. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23123. /**
  23124. * Creates the VertexData of the IcoSphere
  23125. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23126. * * radius the radius of the IcoSphere, optional default 1
  23127. * * radiusX allows stretching in the x direction, optional, default radius
  23128. * * radiusY allows stretching in the y direction, optional, default radius
  23129. * * radiusZ allows stretching in the z direction, optional, default radius
  23130. * * flat when true creates a flat shaded mesh, optional, default true
  23131. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23133. * * 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)
  23134. * * 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)
  23135. * @returns the VertexData of the IcoSphere
  23136. */
  23137. static CreateIcoSphere(options: {
  23138. radius?: number;
  23139. radiusX?: number;
  23140. radiusY?: number;
  23141. radiusZ?: number;
  23142. flat?: boolean;
  23143. subdivisions?: number;
  23144. sideOrientation?: number;
  23145. frontUVs?: Vector4;
  23146. backUVs?: Vector4;
  23147. }): VertexData;
  23148. /**
  23149. * Creates the VertexData for a Polyhedron
  23150. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23151. * * type provided types are:
  23152. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23153. * * 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)
  23154. * * size the size of the IcoSphere, optional default 1
  23155. * * sizeX allows stretching in the x direction, optional, default size
  23156. * * sizeY allows stretching in the y direction, optional, default size
  23157. * * sizeZ allows stretching in the z direction, optional, default size
  23158. * * 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
  23159. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23160. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23161. * * flat when true creates a flat shaded mesh, optional, default true
  23162. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23164. * * 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)
  23165. * * 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)
  23166. * @returns the VertexData of the Polyhedron
  23167. */
  23168. static CreatePolyhedron(options: {
  23169. type?: number;
  23170. size?: number;
  23171. sizeX?: number;
  23172. sizeY?: number;
  23173. sizeZ?: number;
  23174. custom?: any;
  23175. faceUV?: Vector4[];
  23176. faceColors?: Color4[];
  23177. flat?: boolean;
  23178. sideOrientation?: number;
  23179. frontUVs?: Vector4;
  23180. backUVs?: Vector4;
  23181. }): VertexData;
  23182. /**
  23183. * Creates the VertexData for a TorusKnot
  23184. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23185. * * radius the radius of the torus knot, optional, default 2
  23186. * * tube the thickness of the tube, optional, default 0.5
  23187. * * radialSegments the number of sides on each tube segments, optional, default 32
  23188. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23189. * * p the number of windings around the z axis, optional, default 2
  23190. * * q the number of windings around the x axis, optional, default 3
  23191. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23192. * * 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)
  23193. * * 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)
  23194. * @returns the VertexData of the Torus Knot
  23195. */
  23196. static CreateTorusKnot(options: {
  23197. radius?: number;
  23198. tube?: number;
  23199. radialSegments?: number;
  23200. tubularSegments?: number;
  23201. p?: number;
  23202. q?: number;
  23203. sideOrientation?: number;
  23204. frontUVs?: Vector4;
  23205. backUVs?: Vector4;
  23206. }): VertexData;
  23207. /**
  23208. * Compute normals for given positions and indices
  23209. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23210. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23211. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23212. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23213. * * facetNormals : optional array of facet normals (vector3)
  23214. * * facetPositions : optional array of facet positions (vector3)
  23215. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23216. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23217. * * bInfo : optional bounding info, required for facetPartitioning computation
  23218. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23219. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23220. * * useRightHandedSystem: optional boolean to for right handed system computation
  23221. * * depthSort : optional boolean to enable the facet depth sort computation
  23222. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23223. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23224. */
  23225. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23226. facetNormals?: any;
  23227. facetPositions?: any;
  23228. facetPartitioning?: any;
  23229. ratio?: number;
  23230. bInfo?: any;
  23231. bbSize?: Vector3;
  23232. subDiv?: any;
  23233. useRightHandedSystem?: boolean;
  23234. depthSort?: boolean;
  23235. distanceTo?: Vector3;
  23236. depthSortedFacets?: any;
  23237. }): void;
  23238. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23239. /**
  23240. * Applies VertexData created from the imported parameters to the geometry
  23241. * @param parsedVertexData the parsed data from an imported file
  23242. * @param geometry the geometry to apply the VertexData to
  23243. */
  23244. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23245. }
  23246. }
  23247. declare module BABYLON {
  23248. /**
  23249. * Class containing static functions to help procedurally build meshes
  23250. */
  23251. export class DiscBuilder {
  23252. /**
  23253. * Creates a plane polygonal mesh. By default, this is a disc
  23254. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23255. * * 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
  23256. * * 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
  23257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23258. * * 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
  23259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23260. * @param name defines the name of the mesh
  23261. * @param options defines the options used to create the mesh
  23262. * @param scene defines the hosting scene
  23263. * @returns the plane polygonal mesh
  23264. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23265. */
  23266. static CreateDisc(name: string, options: {
  23267. radius?: number;
  23268. tessellation?: number;
  23269. arc?: number;
  23270. updatable?: boolean;
  23271. sideOrientation?: number;
  23272. frontUVs?: Vector4;
  23273. backUVs?: Vector4;
  23274. }, scene?: Nullable<Scene>): Mesh;
  23275. }
  23276. }
  23277. declare module BABYLON {
  23278. /**
  23279. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23280. *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.
  23281. * The SPS is also a particle system. It provides some methods to manage the particles.
  23282. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23283. *
  23284. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23285. */
  23286. export class SolidParticleSystem implements IDisposable {
  23287. /**
  23288. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23289. * Example : var p = SPS.particles[i];
  23290. */
  23291. particles: SolidParticle[];
  23292. /**
  23293. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23294. */
  23295. nbParticles: number;
  23296. /**
  23297. * If the particles must ever face the camera (default false). Useful for planar particles.
  23298. */
  23299. billboard: boolean;
  23300. /**
  23301. * Recompute normals when adding a shape
  23302. */
  23303. recomputeNormals: boolean;
  23304. /**
  23305. * This a counter ofr your own usage. It's not set by any SPS functions.
  23306. */
  23307. counter: number;
  23308. /**
  23309. * The SPS name. This name is also given to the underlying mesh.
  23310. */
  23311. name: string;
  23312. /**
  23313. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23314. */
  23315. mesh: Mesh;
  23316. /**
  23317. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23318. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23319. */
  23320. vars: any;
  23321. /**
  23322. * This array is populated when the SPS is set as 'pickable'.
  23323. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23324. * Each element of this array is an object `{idx: int, faceId: int}`.
  23325. * `idx` is the picked particle index in the `SPS.particles` array
  23326. * `faceId` is the picked face index counted within this particle.
  23327. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23328. */
  23329. pickedParticles: {
  23330. idx: number;
  23331. faceId: number;
  23332. }[];
  23333. /**
  23334. * This array is populated when `enableDepthSort` is set to true.
  23335. * Each element of this array is an instance of the class DepthSortedParticle.
  23336. */
  23337. depthSortedParticles: DepthSortedParticle[];
  23338. /**
  23339. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23340. * @hidden
  23341. */ bSphereOnly: boolean;
  23342. /**
  23343. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23344. * @hidden
  23345. */ bSphereRadiusFactor: number;
  23346. private _scene;
  23347. private _positions;
  23348. private _indices;
  23349. private _normals;
  23350. private _colors;
  23351. private _uvs;
  23352. private _indices32;
  23353. private _positions32;
  23354. private _normals32;
  23355. private _fixedNormal32;
  23356. private _colors32;
  23357. private _uvs32;
  23358. private _index;
  23359. private _updatable;
  23360. private _pickable;
  23361. private _isVisibilityBoxLocked;
  23362. private _alwaysVisible;
  23363. private _depthSort;
  23364. private _shapeCounter;
  23365. private _copy;
  23366. private _color;
  23367. private _computeParticleColor;
  23368. private _computeParticleTexture;
  23369. private _computeParticleRotation;
  23370. private _computeParticleVertex;
  23371. private _computeBoundingBox;
  23372. private _depthSortParticles;
  23373. private _camera;
  23374. private _mustUnrotateFixedNormals;
  23375. private _particlesIntersect;
  23376. private _needs32Bits;
  23377. /**
  23378. * Creates a SPS (Solid Particle System) object.
  23379. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23380. * @param scene (Scene) is the scene in which the SPS is added.
  23381. * @param options defines the options of the sps e.g.
  23382. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23383. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23384. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23385. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23386. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23387. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23388. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23389. */
  23390. constructor(name: string, scene: Scene, options?: {
  23391. updatable?: boolean;
  23392. isPickable?: boolean;
  23393. enableDepthSort?: boolean;
  23394. particleIntersection?: boolean;
  23395. boundingSphereOnly?: boolean;
  23396. bSphereRadiusFactor?: number;
  23397. });
  23398. /**
  23399. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23400. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23401. * @returns the created mesh
  23402. */
  23403. buildMesh(): Mesh;
  23404. /**
  23405. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23406. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23407. * Thus the particles generated from `digest()` have their property `position` set yet.
  23408. * @param mesh ( Mesh ) is the mesh to be digested
  23409. * @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
  23410. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23411. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23412. * @returns the current SPS
  23413. */
  23414. digest(mesh: Mesh, options?: {
  23415. facetNb?: number;
  23416. number?: number;
  23417. delta?: number;
  23418. }): SolidParticleSystem;
  23419. private _unrotateFixedNormals;
  23420. private _resetCopy;
  23421. private _meshBuilder;
  23422. private _posToShape;
  23423. private _uvsToShapeUV;
  23424. private _addParticle;
  23425. /**
  23426. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23427. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23428. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23429. * @param nb (positive integer) the number of particles to be created from this model
  23430. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23431. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23432. * @returns the number of shapes in the system
  23433. */
  23434. addShape(mesh: Mesh, nb: number, options?: {
  23435. positionFunction?: any;
  23436. vertexFunction?: any;
  23437. }): number;
  23438. private _rebuildParticle;
  23439. /**
  23440. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23441. * @returns the SPS.
  23442. */
  23443. rebuildMesh(): SolidParticleSystem;
  23444. /**
  23445. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23446. * This method calls `updateParticle()` for each particle of the SPS.
  23447. * For an animated SPS, it is usually called within the render loop.
  23448. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23449. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23450. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23451. * @returns the SPS.
  23452. */
  23453. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23454. /**
  23455. * Disposes the SPS.
  23456. */
  23457. dispose(): void;
  23458. /**
  23459. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23460. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23461. * @returns the SPS.
  23462. */
  23463. refreshVisibleSize(): SolidParticleSystem;
  23464. /**
  23465. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23466. * @param size the size (float) of the visibility box
  23467. * note : this doesn't lock the SPS mesh bounding box.
  23468. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23469. */
  23470. setVisibilityBox(size: number): void;
  23471. /**
  23472. * Gets whether the SPS as always visible or not
  23473. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23474. */
  23475. /**
  23476. * Sets the SPS as always visible or not
  23477. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23478. */
  23479. isAlwaysVisible: boolean;
  23480. /**
  23481. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23482. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23483. */
  23484. /**
  23485. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23486. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23487. */
  23488. isVisibilityBoxLocked: boolean;
  23489. /**
  23490. * Tells to `setParticles()` to compute the particle rotations or not.
  23491. * Default value : true. The SPS is faster when it's set to false.
  23492. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23493. */
  23494. /**
  23495. * Gets if `setParticles()` computes the particle rotations or not.
  23496. * Default value : true. The SPS is faster when it's set to false.
  23497. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23498. */
  23499. computeParticleRotation: boolean;
  23500. /**
  23501. * Tells to `setParticles()` to compute the particle colors or not.
  23502. * Default value : true. The SPS is faster when it's set to false.
  23503. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23504. */
  23505. /**
  23506. * Gets if `setParticles()` computes the particle colors or not.
  23507. * Default value : true. The SPS is faster when it's set to false.
  23508. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23509. */
  23510. computeParticleColor: boolean;
  23511. /**
  23512. * Gets if `setParticles()` computes the particle textures or not.
  23513. * Default value : true. The SPS is faster when it's set to false.
  23514. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23515. */
  23516. computeParticleTexture: boolean;
  23517. /**
  23518. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23519. * Default value : false. The SPS is faster when it's set to false.
  23520. * Note : the particle custom vertex positions aren't stored values.
  23521. */
  23522. /**
  23523. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23524. * Default value : false. The SPS is faster when it's set to false.
  23525. * Note : the particle custom vertex positions aren't stored values.
  23526. */
  23527. computeParticleVertex: boolean;
  23528. /**
  23529. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23530. */
  23531. /**
  23532. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23533. */
  23534. computeBoundingBox: boolean;
  23535. /**
  23536. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23537. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23538. * Default : `true`
  23539. */
  23540. /**
  23541. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23542. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23543. * Default : `true`
  23544. */
  23545. depthSortParticles: boolean;
  23546. /**
  23547. * This function does nothing. It may be overwritten to set all the particle first values.
  23548. * The SPS doesn't call this function, you may have to call it by your own.
  23549. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23550. */
  23551. initParticles(): void;
  23552. /**
  23553. * This function does nothing. It may be overwritten to recycle a particle.
  23554. * The SPS doesn't call this function, you may have to call it by your own.
  23555. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23556. * @param particle The particle to recycle
  23557. * @returns the recycled particle
  23558. */
  23559. recycleParticle(particle: SolidParticle): SolidParticle;
  23560. /**
  23561. * Updates a particle : this function should be overwritten by the user.
  23562. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23563. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23564. * @example : just set a particle position or velocity and recycle conditions
  23565. * @param particle The particle to update
  23566. * @returns the updated particle
  23567. */
  23568. updateParticle(particle: SolidParticle): SolidParticle;
  23569. /**
  23570. * Updates a vertex of a particle : it can be overwritten by the user.
  23571. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23572. * @param particle the current particle
  23573. * @param vertex the current index of the current particle
  23574. * @param pt the index of the current vertex in the particle shape
  23575. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23576. * @example : just set a vertex particle position
  23577. * @returns the updated vertex
  23578. */
  23579. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23580. /**
  23581. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23582. * This does nothing and may be overwritten by the user.
  23583. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23584. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23585. * @param update the boolean update value actually passed to setParticles()
  23586. */
  23587. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23588. /**
  23589. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23590. * This will be passed three parameters.
  23591. * This does nothing and may be overwritten by the user.
  23592. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23593. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23594. * @param update the boolean update value actually passed to setParticles()
  23595. */
  23596. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23597. }
  23598. }
  23599. declare module BABYLON {
  23600. /**
  23601. * Represents one particle of a solid particle system.
  23602. */
  23603. export class SolidParticle {
  23604. /**
  23605. * particle global index
  23606. */
  23607. idx: number;
  23608. /**
  23609. * The color of the particle
  23610. */
  23611. color: Nullable<Color4>;
  23612. /**
  23613. * The world space position of the particle.
  23614. */
  23615. position: Vector3;
  23616. /**
  23617. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23618. */
  23619. rotation: Vector3;
  23620. /**
  23621. * The world space rotation quaternion of the particle.
  23622. */
  23623. rotationQuaternion: Nullable<Quaternion>;
  23624. /**
  23625. * The scaling of the particle.
  23626. */
  23627. scaling: Vector3;
  23628. /**
  23629. * The uvs of the particle.
  23630. */
  23631. uvs: Vector4;
  23632. /**
  23633. * The current speed of the particle.
  23634. */
  23635. velocity: Vector3;
  23636. /**
  23637. * The pivot point in the particle local space.
  23638. */
  23639. pivot: Vector3;
  23640. /**
  23641. * Must the particle be translated from its pivot point in its local space ?
  23642. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23643. * Default : false
  23644. */
  23645. translateFromPivot: boolean;
  23646. /**
  23647. * Is the particle active or not ?
  23648. */
  23649. alive: boolean;
  23650. /**
  23651. * Is the particle visible or not ?
  23652. */
  23653. isVisible: boolean;
  23654. /**
  23655. * Index of this particle in the global "positions" array (Internal use)
  23656. * @hidden
  23657. */ pos: number;
  23658. /**
  23659. * @hidden Index of this particle in the global "indices" array (Internal use)
  23660. */ ind: number;
  23661. /**
  23662. * @hidden ModelShape of this particle (Internal use)
  23663. */ model: ModelShape;
  23664. /**
  23665. * ModelShape id of this particle
  23666. */
  23667. shapeId: number;
  23668. /**
  23669. * Index of the particle in its shape id (Internal use)
  23670. */
  23671. idxInShape: number;
  23672. /**
  23673. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23674. */ modelBoundingInfo: BoundingInfo;
  23675. /**
  23676. * @hidden Particle BoundingInfo object (Internal use)
  23677. */ boundingInfo: BoundingInfo;
  23678. /**
  23679. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23680. */ sps: SolidParticleSystem;
  23681. /**
  23682. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23683. */ stillInvisible: boolean;
  23684. /**
  23685. * @hidden Last computed particle rotation matrix
  23686. */ rotationMatrix: number[];
  23687. /**
  23688. * Parent particle Id, if any.
  23689. * Default null.
  23690. */
  23691. parentId: Nullable<number>;
  23692. /**
  23693. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23694. * The possible values are :
  23695. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23696. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23697. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23698. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23699. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23700. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23701. * */
  23702. cullingStrategy: number;
  23703. /**
  23704. * @hidden Internal global position in the SPS.
  23705. */ globalPosition: Vector3;
  23706. /**
  23707. * Creates a Solid Particle object.
  23708. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23709. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23710. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23711. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23712. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23713. * @param shapeId (integer) is the model shape identifier in the SPS.
  23714. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23715. * @param sps defines the sps it is associated to
  23716. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23717. */
  23718. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23719. /**
  23720. * Legacy support, changed scale to scaling
  23721. */
  23722. /**
  23723. * Legacy support, changed scale to scaling
  23724. */
  23725. scale: Vector3;
  23726. /**
  23727. * Legacy support, changed quaternion to rotationQuaternion
  23728. */
  23729. /**
  23730. * Legacy support, changed quaternion to rotationQuaternion
  23731. */
  23732. quaternion: Nullable<Quaternion>;
  23733. /**
  23734. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23735. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23736. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23737. * @returns true if it intersects
  23738. */
  23739. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23740. /**
  23741. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23742. * A particle is in the frustum if its bounding box intersects the frustum
  23743. * @param frustumPlanes defines the frustum to test
  23744. * @returns true if the particle is in the frustum planes
  23745. */
  23746. isInFrustum(frustumPlanes: Plane[]): boolean;
  23747. /**
  23748. * get the rotation matrix of the particle
  23749. * @hidden
  23750. */
  23751. getRotationMatrix(m: Matrix): void;
  23752. }
  23753. /**
  23754. * Represents the shape of the model used by one particle of a solid particle system.
  23755. * SPS internal tool, don't use it manually.
  23756. */
  23757. export class ModelShape {
  23758. /**
  23759. * The shape id
  23760. * @hidden
  23761. */
  23762. shapeID: number;
  23763. /**
  23764. * flat array of model positions (internal use)
  23765. * @hidden
  23766. */ shape: Vector3[];
  23767. /**
  23768. * flat array of model UVs (internal use)
  23769. * @hidden
  23770. */ shapeUV: number[];
  23771. /**
  23772. * length of the shape in the model indices array (internal use)
  23773. * @hidden
  23774. */ indicesLength: number;
  23775. /**
  23776. * Custom position function (internal use)
  23777. * @hidden
  23778. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23779. /**
  23780. * Custom vertex function (internal use)
  23781. * @hidden
  23782. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23783. /**
  23784. * 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.
  23785. * SPS internal tool, don't use it manually.
  23786. * @hidden
  23787. */
  23788. 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>);
  23789. }
  23790. /**
  23791. * Represents a Depth Sorted Particle in the solid particle system.
  23792. */
  23793. export class DepthSortedParticle {
  23794. /**
  23795. * Index of the particle in the "indices" array
  23796. */
  23797. ind: number;
  23798. /**
  23799. * Length of the particle shape in the "indices" array
  23800. */
  23801. indicesLength: number;
  23802. /**
  23803. * Squared distance from the particle to the camera
  23804. */
  23805. sqDistance: number;
  23806. }
  23807. }
  23808. declare module BABYLON {
  23809. /**
  23810. * Class used to store all common mesh properties
  23811. */
  23812. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23813. /** No occlusion */
  23814. static OCCLUSION_TYPE_NONE: number;
  23815. /** Occlusion set to optimisitic */
  23816. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23817. /** Occlusion set to strict */
  23818. static OCCLUSION_TYPE_STRICT: number;
  23819. /** Use an accurante occlusion algorithm */
  23820. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23821. /** Use a conservative occlusion algorithm */
  23822. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23823. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23824. * Test order :
  23825. * Is the bounding sphere outside the frustum ?
  23826. * If not, are the bounding box vertices outside the frustum ?
  23827. * It not, then the cullable object is in the frustum.
  23828. */
  23829. static readonly CULLINGSTRATEGY_STANDARD: number;
  23830. /** Culling strategy : Bounding Sphere Only.
  23831. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23832. * It's also less accurate than the standard because some not visible objects can still be selected.
  23833. * Test : is the bounding sphere outside the frustum ?
  23834. * If not, then the cullable object is in the frustum.
  23835. */
  23836. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23837. /** Culling strategy : Optimistic Inclusion.
  23838. * This in an inclusion test first, then the standard exclusion test.
  23839. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23840. * 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.
  23841. * Anyway, it's as accurate as the standard strategy.
  23842. * Test :
  23843. * Is the cullable object bounding sphere center in the frustum ?
  23844. * If not, apply the default culling strategy.
  23845. */
  23846. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23847. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23848. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23849. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23850. * 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.
  23851. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23852. * Test :
  23853. * Is the cullable object bounding sphere center in the frustum ?
  23854. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23855. */
  23856. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23857. /**
  23858. * No billboard
  23859. */
  23860. static readonly BILLBOARDMODE_NONE: number;
  23861. /** Billboard on X axis */
  23862. static readonly BILLBOARDMODE_X: number;
  23863. /** Billboard on Y axis */
  23864. static readonly BILLBOARDMODE_Y: number;
  23865. /** Billboard on Z axis */
  23866. static readonly BILLBOARDMODE_Z: number;
  23867. /** Billboard on all axes */
  23868. static readonly BILLBOARDMODE_ALL: number;
  23869. private _facetData;
  23870. /**
  23871. * The culling strategy to use to check whether the mesh must be rendered or not.
  23872. * This value can be changed at any time and will be used on the next render mesh selection.
  23873. * The possible values are :
  23874. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23875. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23876. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23877. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23878. * Please read each static variable documentation to get details about the culling process.
  23879. * */
  23880. cullingStrategy: number;
  23881. /**
  23882. * Gets the number of facets in the mesh
  23883. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23884. */
  23885. readonly facetNb: number;
  23886. /**
  23887. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23888. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23889. */
  23890. partitioningSubdivisions: number;
  23891. /**
  23892. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23893. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23895. */
  23896. partitioningBBoxRatio: number;
  23897. /**
  23898. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23899. * Works only for updatable meshes.
  23900. * Doesn't work with multi-materials
  23901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23902. */
  23903. mustDepthSortFacets: boolean;
  23904. /**
  23905. * The location (Vector3) where the facet depth sort must be computed from.
  23906. * By default, the active camera position.
  23907. * Used only when facet depth sort is enabled
  23908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23909. */
  23910. facetDepthSortFrom: Vector3;
  23911. /**
  23912. * gets a boolean indicating if facetData is enabled
  23913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23914. */
  23915. readonly isFacetDataEnabled: boolean;
  23916. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  23917. /**
  23918. * An event triggered when this mesh collides with another one
  23919. */
  23920. onCollideObservable: Observable<AbstractMesh>;
  23921. private _onCollideObserver;
  23922. /** Set a function to call when this mesh collides with another one */
  23923. onCollide: () => void;
  23924. /**
  23925. * An event triggered when the collision's position changes
  23926. */
  23927. onCollisionPositionChangeObservable: Observable<Vector3>;
  23928. private _onCollisionPositionChangeObserver;
  23929. /** Set a function to call when the collision's position changes */
  23930. onCollisionPositionChange: () => void;
  23931. /**
  23932. * An event triggered when material is changed
  23933. */
  23934. onMaterialChangedObservable: Observable<AbstractMesh>;
  23935. /**
  23936. * Gets or sets the orientation for POV movement & rotation
  23937. */
  23938. definedFacingForward: boolean;
  23939. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  23940. private _visibility;
  23941. /** @hidden */ isActive: boolean;
  23942. /** @hidden */ onlyForInstances: boolean;
  23943. /** @hidden */ renderingGroup: Nullable<RenderingGroup>;
  23944. /**
  23945. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23946. */
  23947. /**
  23948. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23949. */
  23950. visibility: number;
  23951. /** Gets or sets the alpha index used to sort transparent meshes
  23952. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23953. */
  23954. alphaIndex: number;
  23955. /**
  23956. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23957. */
  23958. isVisible: boolean;
  23959. /**
  23960. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23961. */
  23962. isPickable: boolean;
  23963. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23964. showSubMeshesBoundingBox: boolean;
  23965. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23966. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23967. */
  23968. isBlocker: boolean;
  23969. /**
  23970. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23971. */
  23972. enablePointerMoveEvents: boolean;
  23973. /**
  23974. * Specifies the rendering group id for this mesh (0 by default)
  23975. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23976. */
  23977. renderingGroupId: number;
  23978. private _material;
  23979. /** Gets or sets current material */
  23980. material: Nullable<Material>;
  23981. private _receiveShadows;
  23982. /**
  23983. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23984. * @see http://doc.babylonjs.com/babylon101/shadows
  23985. */
  23986. receiveShadows: boolean;
  23987. /** Defines color to use when rendering outline */
  23988. outlineColor: Color3;
  23989. /** Define width to use when rendering outline */
  23990. outlineWidth: number;
  23991. /** Defines color to use when rendering overlay */
  23992. overlayColor: Color3;
  23993. /** Defines alpha to use when rendering overlay */
  23994. overlayAlpha: number;
  23995. private _hasVertexAlpha;
  23996. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23997. hasVertexAlpha: boolean;
  23998. private _useVertexColors;
  23999. /** 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) */
  24000. useVertexColors: boolean;
  24001. private _computeBonesUsingShaders;
  24002. /**
  24003. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24004. */
  24005. computeBonesUsingShaders: boolean;
  24006. private _numBoneInfluencers;
  24007. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24008. numBoneInfluencers: number;
  24009. private _applyFog;
  24010. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24011. applyFog: boolean;
  24012. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24013. useOctreeForRenderingSelection: boolean;
  24014. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24015. useOctreeForPicking: boolean;
  24016. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24017. useOctreeForCollisions: boolean;
  24018. private _layerMask;
  24019. /**
  24020. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24021. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24022. */
  24023. layerMask: number;
  24024. /**
  24025. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24026. */
  24027. alwaysSelectAsActiveMesh: boolean;
  24028. /**
  24029. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24030. */
  24031. doNotSyncBoundingInfo: boolean;
  24032. /**
  24033. * Gets or sets the current action manager
  24034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24035. */
  24036. actionManager: Nullable<AbstractActionManager>;
  24037. private _checkCollisions;
  24038. private _collisionMask;
  24039. private _collisionGroup;
  24040. /**
  24041. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24042. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24043. */
  24044. ellipsoid: Vector3;
  24045. /**
  24046. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24047. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24048. */
  24049. ellipsoidOffset: Vector3;
  24050. private _collider;
  24051. private _oldPositionForCollisions;
  24052. private _diffPositionForCollisions;
  24053. /**
  24054. * Gets or sets a collision mask used to mask collisions (default is -1).
  24055. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24056. */
  24057. collisionMask: number;
  24058. /**
  24059. * Gets or sets the current collision group mask (-1 by default).
  24060. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24061. */
  24062. collisionGroup: number;
  24063. /**
  24064. * Defines edge width used when edgesRenderer is enabled
  24065. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24066. */
  24067. edgesWidth: number;
  24068. /**
  24069. * Defines edge color used when edgesRenderer is enabled
  24070. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24071. */
  24072. edgesColor: Color4;
  24073. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  24074. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  24075. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  24076. /** @hidden */ renderId: number;
  24077. /**
  24078. * Gets or sets the list of subMeshes
  24079. * @see http://doc.babylonjs.com/how_to/multi_materials
  24080. */
  24081. subMeshes: SubMesh[];
  24082. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  24083. /** @hidden */ unIndexed: boolean;
  24084. /** @hidden */ lightSources: Light[];
  24085. /** Gets the list of lights affecting that mesh */
  24086. readonly lightSources: Light[];
  24087. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  24088. /** @hidden */ waitingActions: Nullable<any>;
  24089. /** @hidden */ waitingFreezeWorldMatrix: Nullable<boolean>;
  24090. private _skeleton;
  24091. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  24092. /**
  24093. * Gets or sets a skeleton to apply skining transformations
  24094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24095. */
  24096. skeleton: Nullable<Skeleton>;
  24097. /**
  24098. * An event triggered when the mesh is rebuilt.
  24099. */
  24100. onRebuildObservable: Observable<AbstractMesh>;
  24101. /**
  24102. * Creates a new AbstractMesh
  24103. * @param name defines the name of the mesh
  24104. * @param scene defines the hosting scene
  24105. */
  24106. constructor(name: string, scene?: Nullable<Scene>);
  24107. /**
  24108. * Returns the string "AbstractMesh"
  24109. * @returns "AbstractMesh"
  24110. */
  24111. getClassName(): string;
  24112. /**
  24113. * Gets a string representation of the current mesh
  24114. * @param fullDetails defines a boolean indicating if full details must be included
  24115. * @returns a string representation of the current mesh
  24116. */
  24117. toString(fullDetails?: boolean): string;
  24118. /**
  24119. * @hidden
  24120. */
  24121. protected _getEffectiveParent(): Nullable<Node>;
  24122. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24123. /** @hidden */ rebuild(): void;
  24124. /** @hidden */ resyncLightSources(): void;
  24125. /** @hidden */ resyncLighSource(light: Light): void;
  24126. /** @hidden */ unBindEffect(): void;
  24127. /** @hidden */ removeLightSource(light: Light): void;
  24128. private _markSubMeshesAsDirty;
  24129. /** @hidden */ markSubMeshesAsLightDirty(): void;
  24130. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  24131. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  24132. /**
  24133. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24134. */
  24135. scaling: Vector3;
  24136. /**
  24137. * Returns true if the mesh is blocked. Implemented by child classes
  24138. */
  24139. readonly isBlocked: boolean;
  24140. /**
  24141. * Returns the mesh itself by default. Implemented by child classes
  24142. * @param camera defines the camera to use to pick the right LOD level
  24143. * @returns the currentAbstractMesh
  24144. */
  24145. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24146. /**
  24147. * Returns 0 by default. Implemented by child classes
  24148. * @returns an integer
  24149. */
  24150. getTotalVertices(): number;
  24151. /**
  24152. * Returns a positive integer : the total number of indices in this mesh geometry.
  24153. * @returns the numner of indices or zero if the mesh has no geometry.
  24154. */
  24155. getTotalIndices(): number;
  24156. /**
  24157. * Returns null by default. Implemented by child classes
  24158. * @returns null
  24159. */
  24160. getIndices(): Nullable<IndicesArray>;
  24161. /**
  24162. * Returns the array of the requested vertex data kind. Implemented by child classes
  24163. * @param kind defines the vertex data kind to use
  24164. * @returns null
  24165. */
  24166. getVerticesData(kind: string): Nullable<FloatArray>;
  24167. /**
  24168. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24169. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24170. * Note that a new underlying VertexBuffer object is created each call.
  24171. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24172. * @param kind defines vertex data kind:
  24173. * * VertexBuffer.PositionKind
  24174. * * VertexBuffer.UVKind
  24175. * * VertexBuffer.UV2Kind
  24176. * * VertexBuffer.UV3Kind
  24177. * * VertexBuffer.UV4Kind
  24178. * * VertexBuffer.UV5Kind
  24179. * * VertexBuffer.UV6Kind
  24180. * * VertexBuffer.ColorKind
  24181. * * VertexBuffer.MatricesIndicesKind
  24182. * * VertexBuffer.MatricesIndicesExtraKind
  24183. * * VertexBuffer.MatricesWeightsKind
  24184. * * VertexBuffer.MatricesWeightsExtraKind
  24185. * @param data defines the data source
  24186. * @param updatable defines if the data must be flagged as updatable (or static)
  24187. * @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
  24188. * @returns the current mesh
  24189. */
  24190. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24191. /**
  24192. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24193. * If the mesh has no geometry, it is simply returned as it is.
  24194. * @param kind defines vertex data kind:
  24195. * * VertexBuffer.PositionKind
  24196. * * VertexBuffer.UVKind
  24197. * * VertexBuffer.UV2Kind
  24198. * * VertexBuffer.UV3Kind
  24199. * * VertexBuffer.UV4Kind
  24200. * * VertexBuffer.UV5Kind
  24201. * * VertexBuffer.UV6Kind
  24202. * * VertexBuffer.ColorKind
  24203. * * VertexBuffer.MatricesIndicesKind
  24204. * * VertexBuffer.MatricesIndicesExtraKind
  24205. * * VertexBuffer.MatricesWeightsKind
  24206. * * VertexBuffer.MatricesWeightsExtraKind
  24207. * @param data defines the data source
  24208. * @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
  24209. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24210. * @returns the current mesh
  24211. */
  24212. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24213. /**
  24214. * Sets the mesh indices,
  24215. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24216. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24217. * @param totalVertices Defines the total number of vertices
  24218. * @returns the current mesh
  24219. */
  24220. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24221. /**
  24222. * Gets a boolean indicating if specific vertex data is present
  24223. * @param kind defines the vertex data kind to use
  24224. * @returns true is data kind is present
  24225. */
  24226. isVerticesDataPresent(kind: string): boolean;
  24227. /**
  24228. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24229. * @returns a BoundingInfo
  24230. */
  24231. getBoundingInfo(): BoundingInfo;
  24232. /**
  24233. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24234. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24235. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24236. * @returns the current mesh
  24237. */
  24238. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24239. /**
  24240. * Overwrite the current bounding info
  24241. * @param boundingInfo defines the new bounding info
  24242. * @returns the current mesh
  24243. */
  24244. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24245. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24246. readonly useBones: boolean;
  24247. /** @hidden */ preActivate(): void;
  24248. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  24249. /** @hidden */ activate(renderId: number): boolean;
  24250. /** @hidden */ freeze(): void;
  24251. /** @hidden */ unFreeze(): void;
  24252. /**
  24253. * Gets the current world matrix
  24254. * @returns a Matrix
  24255. */
  24256. getWorldMatrix(): Matrix;
  24257. /** @hidden */ getWorldMatrixDeterminant(): number;
  24258. /**
  24259. * Perform relative position change from the point of view of behind the front of the mesh.
  24260. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24261. * Supports definition of mesh facing forward or backward
  24262. * @param amountRight defines the distance on the right axis
  24263. * @param amountUp defines the distance on the up axis
  24264. * @param amountForward defines the distance on the forward axis
  24265. * @returns the current mesh
  24266. */
  24267. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24268. /**
  24269. * Calculate relative position change from the point of view of behind the front of the mesh.
  24270. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24271. * Supports definition of mesh facing forward or backward
  24272. * @param amountRight defines the distance on the right axis
  24273. * @param amountUp defines the distance on the up axis
  24274. * @param amountForward defines the distance on the forward axis
  24275. * @returns the new displacement vector
  24276. */
  24277. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24278. /**
  24279. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24280. * Supports definition of mesh facing forward or backward
  24281. * @param flipBack defines the flip
  24282. * @param twirlClockwise defines the twirl
  24283. * @param tiltRight defines the tilt
  24284. * @returns the current mesh
  24285. */
  24286. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24287. /**
  24288. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24289. * Supports definition of mesh facing forward or backward.
  24290. * @param flipBack defines the flip
  24291. * @param twirlClockwise defines the twirl
  24292. * @param tiltRight defines the tilt
  24293. * @returns the new rotation vector
  24294. */
  24295. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24296. /**
  24297. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24298. * This means the mesh underlying bounding box and sphere are recomputed.
  24299. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24300. * @returns the current mesh
  24301. */
  24302. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24303. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24304. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24305. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  24306. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24307. /** @hidden */
  24308. protected _afterComputeWorldMatrix(): void;
  24309. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  24310. /**
  24311. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24312. * A mesh is in the frustum if its bounding box intersects the frustum
  24313. * @param frustumPlanes defines the frustum to test
  24314. * @returns true if the mesh is in the frustum planes
  24315. */
  24316. isInFrustum(frustumPlanes: Plane[]): boolean;
  24317. /**
  24318. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24319. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24320. * @param frustumPlanes defines the frustum to test
  24321. * @returns true if the mesh is completely in the frustum planes
  24322. */
  24323. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24324. /**
  24325. * True if the mesh intersects another mesh or a SolidParticle object
  24326. * @param mesh defines a target mesh or SolidParticle to test
  24327. * @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)
  24328. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24329. * @returns true if there is an intersection
  24330. */
  24331. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24332. /**
  24333. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24334. * @param point defines the point to test
  24335. * @returns true if there is an intersection
  24336. */
  24337. intersectsPoint(point: Vector3): boolean;
  24338. /**
  24339. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24340. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24341. */
  24342. checkCollisions: boolean;
  24343. /**
  24344. * Gets Collider object used to compute collisions (not physics)
  24345. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24346. */
  24347. readonly collider: Nullable<Collider>;
  24348. /**
  24349. * Move the mesh using collision engine
  24350. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24351. * @param displacement defines the requested displacement vector
  24352. * @returns the current mesh
  24353. */
  24354. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24355. private _onCollisionPositionChange;
  24356. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24357. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24358. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  24359. /** @hidden */ generatePointsArray(): boolean;
  24360. /**
  24361. * Checks if the passed Ray intersects with the mesh
  24362. * @param ray defines the ray to use
  24363. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24364. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24365. * @returns the picking info
  24366. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24367. */
  24368. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24369. /**
  24370. * Clones the current mesh
  24371. * @param name defines the mesh name
  24372. * @param newParent defines the new mesh parent
  24373. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24374. * @returns the new mesh
  24375. */
  24376. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24377. /**
  24378. * Disposes all the submeshes of the current meshnp
  24379. * @returns the current mesh
  24380. */
  24381. releaseSubMeshes(): AbstractMesh;
  24382. /**
  24383. * Releases resources associated with this abstract mesh.
  24384. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24385. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24386. */
  24387. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24388. /**
  24389. * Adds the passed mesh as a child to the current mesh
  24390. * @param mesh defines the child mesh
  24391. * @returns the current mesh
  24392. */
  24393. addChild(mesh: AbstractMesh): AbstractMesh;
  24394. /**
  24395. * Removes the passed mesh from the current mesh children list
  24396. * @param mesh defines the child mesh
  24397. * @returns the current mesh
  24398. */
  24399. removeChild(mesh: AbstractMesh): AbstractMesh;
  24400. /** @hidden */
  24401. private _initFacetData;
  24402. /**
  24403. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24404. * This method can be called within the render loop.
  24405. * 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
  24406. * @returns the current mesh
  24407. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24408. */
  24409. updateFacetData(): AbstractMesh;
  24410. /**
  24411. * Returns the facetLocalNormals array.
  24412. * The normals are expressed in the mesh local spac
  24413. * @returns an array of Vector3
  24414. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24415. */
  24416. getFacetLocalNormals(): Vector3[];
  24417. /**
  24418. * Returns the facetLocalPositions array.
  24419. * The facet positions are expressed in the mesh local space
  24420. * @returns an array of Vector3
  24421. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24422. */
  24423. getFacetLocalPositions(): Vector3[];
  24424. /**
  24425. * Returns the facetLocalPartioning array
  24426. * @returns an array of array of numbers
  24427. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24428. */
  24429. getFacetLocalPartitioning(): number[][];
  24430. /**
  24431. * Returns the i-th facet position in the world system.
  24432. * This method allocates a new Vector3 per call
  24433. * @param i defines the facet index
  24434. * @returns a new Vector3
  24435. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24436. */
  24437. getFacetPosition(i: number): Vector3;
  24438. /**
  24439. * Sets the reference Vector3 with the i-th facet position in the world system
  24440. * @param i defines the facet index
  24441. * @param ref defines the target vector
  24442. * @returns the current mesh
  24443. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24444. */
  24445. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24446. /**
  24447. * Returns the i-th facet normal in the world system.
  24448. * This method allocates a new Vector3 per call
  24449. * @param i defines the facet index
  24450. * @returns a new Vector3
  24451. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24452. */
  24453. getFacetNormal(i: number): Vector3;
  24454. /**
  24455. * Sets the reference Vector3 with the i-th facet normal in the world system
  24456. * @param i defines the facet index
  24457. * @param ref defines the target vector
  24458. * @returns the current mesh
  24459. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24460. */
  24461. getFacetNormalToRef(i: number, ref: Vector3): this;
  24462. /**
  24463. * 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)
  24464. * @param x defines x coordinate
  24465. * @param y defines y coordinate
  24466. * @param z defines z coordinate
  24467. * @returns the array of facet indexes
  24468. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24469. */
  24470. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24471. /**
  24472. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24473. * @param projected sets as the (x,y,z) world projection on the facet
  24474. * @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
  24475. * @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
  24476. * @param x defines x coordinate
  24477. * @param y defines y coordinate
  24478. * @param z defines z coordinate
  24479. * @returns the face index if found (or null instead)
  24480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24481. */
  24482. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24483. /**
  24484. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24485. * @param projected sets as the (x,y,z) local projection on the facet
  24486. * @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
  24487. * @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
  24488. * @param x defines x coordinate
  24489. * @param y defines y coordinate
  24490. * @param z defines z coordinate
  24491. * @returns the face index if found (or null instead)
  24492. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24493. */
  24494. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24495. /**
  24496. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24497. * @returns the parameters
  24498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24499. */
  24500. getFacetDataParameters(): any;
  24501. /**
  24502. * Disables the feature FacetData and frees the related memory
  24503. * @returns the current mesh
  24504. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24505. */
  24506. disableFacetData(): AbstractMesh;
  24507. /**
  24508. * Updates the AbstractMesh indices array
  24509. * @param indices defines the data source
  24510. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24511. * @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)
  24512. * @returns the current mesh
  24513. */
  24514. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24515. /**
  24516. * Creates new normals data for the mesh
  24517. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24518. * @returns the current mesh
  24519. */
  24520. createNormals(updatable: boolean): AbstractMesh;
  24521. /**
  24522. * Align the mesh with a normal
  24523. * @param normal defines the normal to use
  24524. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24525. * @returns the current mesh
  24526. */
  24527. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24528. /** @hidden */ checkOcclusionQuery(): boolean;
  24529. }
  24530. }
  24531. declare module BABYLON {
  24532. /**
  24533. * Interface used to define ActionEvent
  24534. */
  24535. export interface IActionEvent {
  24536. /** The mesh or sprite that triggered the action */
  24537. source: any;
  24538. /** The X mouse cursor position at the time of the event */
  24539. pointerX: number;
  24540. /** The Y mouse cursor position at the time of the event */
  24541. pointerY: number;
  24542. /** The mesh that is currently pointed at (can be null) */
  24543. meshUnderPointer: Nullable<AbstractMesh>;
  24544. /** the original (browser) event that triggered the ActionEvent */
  24545. sourceEvent?: any;
  24546. /** additional data for the event */
  24547. additionalData?: any;
  24548. }
  24549. /**
  24550. * ActionEvent is the event being sent when an action is triggered.
  24551. */
  24552. export class ActionEvent implements IActionEvent {
  24553. /** The mesh or sprite that triggered the action */
  24554. source: any;
  24555. /** The X mouse cursor position at the time of the event */
  24556. pointerX: number;
  24557. /** The Y mouse cursor position at the time of the event */
  24558. pointerY: number;
  24559. /** The mesh that is currently pointed at (can be null) */
  24560. meshUnderPointer: Nullable<AbstractMesh>;
  24561. /** the original (browser) event that triggered the ActionEvent */
  24562. sourceEvent?: any;
  24563. /** additional data for the event */
  24564. additionalData?: any;
  24565. /**
  24566. * Creates a new ActionEvent
  24567. * @param source The mesh or sprite that triggered the action
  24568. * @param pointerX The X mouse cursor position at the time of the event
  24569. * @param pointerY The Y mouse cursor position at the time of the event
  24570. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24571. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24572. * @param additionalData additional data for the event
  24573. */
  24574. constructor(
  24575. /** The mesh or sprite that triggered the action */
  24576. source: any,
  24577. /** The X mouse cursor position at the time of the event */
  24578. pointerX: number,
  24579. /** The Y mouse cursor position at the time of the event */
  24580. pointerY: number,
  24581. /** The mesh that is currently pointed at (can be null) */
  24582. meshUnderPointer: Nullable<AbstractMesh>,
  24583. /** the original (browser) event that triggered the ActionEvent */
  24584. sourceEvent?: any,
  24585. /** additional data for the event */
  24586. additionalData?: any);
  24587. /**
  24588. * Helper function to auto-create an ActionEvent from a source mesh.
  24589. * @param source The source mesh that triggered the event
  24590. * @param evt The original (browser) event
  24591. * @param additionalData additional data for the event
  24592. * @returns the new ActionEvent
  24593. */
  24594. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24595. /**
  24596. * Helper function to auto-create an ActionEvent from a source sprite
  24597. * @param source The source sprite that triggered the event
  24598. * @param scene Scene associated with the sprite
  24599. * @param evt The original (browser) event
  24600. * @param additionalData additional data for the event
  24601. * @returns the new ActionEvent
  24602. */
  24603. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24604. /**
  24605. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24606. * @param scene the scene where the event occurred
  24607. * @param evt The original (browser) event
  24608. * @returns the new ActionEvent
  24609. */
  24610. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24611. /**
  24612. * Helper function to auto-create an ActionEvent from a primitive
  24613. * @param prim defines the target primitive
  24614. * @param pointerPos defines the pointer position
  24615. * @param evt The original (browser) event
  24616. * @param additionalData additional data for the event
  24617. * @returns the new ActionEvent
  24618. */
  24619. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24620. }
  24621. }
  24622. declare module BABYLON {
  24623. /**
  24624. * Abstract class used to decouple action Manager from scene and meshes.
  24625. * Do not instantiate.
  24626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24627. */
  24628. export abstract class AbstractActionManager implements IDisposable {
  24629. /** Gets the list of active triggers */
  24630. static Triggers: {
  24631. [key: string]: number;
  24632. };
  24633. /** Gets the cursor to use when hovering items */
  24634. hoverCursor: string;
  24635. /** Gets the list of actions */
  24636. actions: IAction[];
  24637. /**
  24638. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24639. */
  24640. isRecursive: boolean;
  24641. /**
  24642. * Releases all associated resources
  24643. */
  24644. abstract dispose(): void;
  24645. /**
  24646. * Does this action manager has pointer triggers
  24647. */
  24648. abstract readonly hasPointerTriggers: boolean;
  24649. /**
  24650. * Does this action manager has pick triggers
  24651. */
  24652. abstract readonly hasPickTriggers: boolean;
  24653. /**
  24654. * Process a specific trigger
  24655. * @param trigger defines the trigger to process
  24656. * @param evt defines the event details to be processed
  24657. */
  24658. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24659. /**
  24660. * Does this action manager handles actions of any of the given triggers
  24661. * @param triggers defines the triggers to be tested
  24662. * @return a boolean indicating whether one (or more) of the triggers is handled
  24663. */
  24664. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24665. /**
  24666. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24667. * speed.
  24668. * @param triggerA defines the trigger to be tested
  24669. * @param triggerB defines the trigger to be tested
  24670. * @return a boolean indicating whether one (or more) of the triggers is handled
  24671. */
  24672. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24673. /**
  24674. * Does this action manager handles actions of a given trigger
  24675. * @param trigger defines the trigger to be tested
  24676. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24677. * @return whether the trigger is handled
  24678. */
  24679. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24680. /**
  24681. * Serialize this manager to a JSON object
  24682. * @param name defines the property name to store this manager
  24683. * @returns a JSON representation of this manager
  24684. */
  24685. abstract serialize(name: string): any;
  24686. /**
  24687. * Registers an action to this action manager
  24688. * @param action defines the action to be registered
  24689. * @return the action amended (prepared) after registration
  24690. */
  24691. abstract registerAction(action: IAction): Nullable<IAction>;
  24692. /**
  24693. * Unregisters an action to this action manager
  24694. * @param action defines the action to be unregistered
  24695. * @return a boolean indicating whether the action has been unregistered
  24696. */
  24697. abstract unregisterAction(action: IAction): Boolean;
  24698. /**
  24699. * Does exist one action manager with at least one trigger
  24700. **/
  24701. static readonly HasTriggers: boolean;
  24702. /**
  24703. * Does exist one action manager with at least one pick trigger
  24704. **/
  24705. static readonly HasPickTriggers: boolean;
  24706. /**
  24707. * Does exist one action manager that handles actions of a given trigger
  24708. * @param trigger defines the trigger to be tested
  24709. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24710. **/
  24711. static HasSpecificTrigger(trigger: number): boolean;
  24712. }
  24713. }
  24714. declare module BABYLON {
  24715. /**
  24716. * Defines how a node can be built from a string name.
  24717. */
  24718. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24719. /**
  24720. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24721. */
  24722. export class Node implements IBehaviorAware<Node> {
  24723. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24724. private static _NodeConstructors;
  24725. /**
  24726. * Add a new node constructor
  24727. * @param type defines the type name of the node to construct
  24728. * @param constructorFunc defines the constructor function
  24729. */
  24730. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24731. /**
  24732. * Returns a node constructor based on type name
  24733. * @param type defines the type name
  24734. * @param name defines the new node name
  24735. * @param scene defines the hosting scene
  24736. * @param options defines optional options to transmit to constructors
  24737. * @returns the new constructor or null
  24738. */
  24739. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24740. /**
  24741. * Gets or sets the name of the node
  24742. */
  24743. name: string;
  24744. /**
  24745. * Gets or sets the id of the node
  24746. */
  24747. id: string;
  24748. /**
  24749. * Gets or sets the unique id of the node
  24750. */
  24751. uniqueId: number;
  24752. /**
  24753. * Gets or sets a string used to store user defined state for the node
  24754. */
  24755. state: string;
  24756. /**
  24757. * Gets or sets an object used to store user defined information for the node
  24758. */
  24759. metadata: any;
  24760. /**
  24761. * For internal use only. Please do not use.
  24762. */
  24763. reservedDataStore: any;
  24764. /**
  24765. * List of inspectable custom properties (used by the Inspector)
  24766. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24767. */
  24768. inspectableCustomProperties: IInspectable[];
  24769. /**
  24770. * Gets or sets a boolean used to define if the node must be serialized
  24771. */
  24772. doNotSerialize: boolean;
  24773. /** @hidden */ isDisposed: boolean;
  24774. /**
  24775. * Gets a list of Animations associated with the node
  24776. */
  24777. animations: Animation[];
  24778. protected _ranges: {
  24779. [name: string]: Nullable<AnimationRange>;
  24780. };
  24781. /**
  24782. * Callback raised when the node is ready to be used
  24783. */
  24784. onReady: Nullable<(node: Node) => void>;
  24785. private _isEnabled;
  24786. private _isParentEnabled;
  24787. private _isReady;
  24788. /** @hidden */ currentRenderId: number;
  24789. private _parentUpdateId;
  24790. /** @hidden */ childUpdateId: number;
  24791. /** @hidden */ waitingParentId: Nullable<string>;
  24792. /** @hidden */ scene: Scene;
  24793. /** @hidden */ cache: any;
  24794. private _parentNode;
  24795. private _children;
  24796. /** @hidden */ worldMatrix: Matrix;
  24797. /** @hidden */ worldMatrixDeterminant: number;
  24798. /** @hidden */ worldMatrixDeterminantIsDirty: boolean;
  24799. /** @hidden */
  24800. private _sceneRootNodesIndex;
  24801. /**
  24802. * Gets a boolean indicating if the node has been disposed
  24803. * @returns true if the node was disposed
  24804. */
  24805. isDisposed(): boolean;
  24806. /**
  24807. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24808. * @see https://doc.babylonjs.com/how_to/parenting
  24809. */
  24810. parent: Nullable<Node>;
  24811. private addToSceneRootNodes;
  24812. private removeFromSceneRootNodes;
  24813. private _animationPropertiesOverride;
  24814. /**
  24815. * Gets or sets the animation properties override
  24816. */
  24817. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24818. /**
  24819. * Gets a string idenfifying the name of the class
  24820. * @returns "Node" string
  24821. */
  24822. getClassName(): string;
  24823. /** @hidden */ protected readonly _isNode: boolean;
  24824. /**
  24825. * An event triggered when the mesh is disposed
  24826. */
  24827. onDisposeObservable: Observable<Node>;
  24828. private _onDisposeObserver;
  24829. /**
  24830. * Sets a callback that will be raised when the node will be disposed
  24831. */
  24832. onDispose: () => void;
  24833. /**
  24834. * Creates a new Node
  24835. * @param name the name and id to be given to this node
  24836. * @param scene the scene this node will be added to
  24837. * @param addToRootNodes the node will be added to scene.rootNodes
  24838. */
  24839. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24840. /**
  24841. * Gets the scene of the node
  24842. * @returns a scene
  24843. */
  24844. getScene(): Scene;
  24845. /**
  24846. * Gets the engine of the node
  24847. * @returns a Engine
  24848. */
  24849. getEngine(): Engine;
  24850. private _behaviors;
  24851. /**
  24852. * Attach a behavior to the node
  24853. * @see http://doc.babylonjs.com/features/behaviour
  24854. * @param behavior defines the behavior to attach
  24855. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24856. * @returns the current Node
  24857. */
  24858. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24859. /**
  24860. * Remove an attached behavior
  24861. * @see http://doc.babylonjs.com/features/behaviour
  24862. * @param behavior defines the behavior to attach
  24863. * @returns the current Node
  24864. */
  24865. removeBehavior(behavior: Behavior<Node>): Node;
  24866. /**
  24867. * Gets the list of attached behaviors
  24868. * @see http://doc.babylonjs.com/features/behaviour
  24869. */
  24870. readonly behaviors: Behavior<Node>[];
  24871. /**
  24872. * Gets an attached behavior by name
  24873. * @param name defines the name of the behavior to look for
  24874. * @see http://doc.babylonjs.com/features/behaviour
  24875. * @returns null if behavior was not found else the requested behavior
  24876. */
  24877. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24878. /**
  24879. * Returns the latest update of the World matrix
  24880. * @returns a Matrix
  24881. */
  24882. getWorldMatrix(): Matrix;
  24883. /** @hidden */ getWorldMatrixDeterminant(): number;
  24884. /**
  24885. * Returns directly the latest state of the mesh World matrix.
  24886. * A Matrix is returned.
  24887. */
  24888. readonly worldMatrixFromCache: Matrix;
  24889. /** @hidden */ initCache(): void;
  24890. /** @hidden */
  24891. updateCache(force?: boolean): void;
  24892. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24893. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  24894. /** @hidden */ isSynchronized(): boolean;
  24895. /** @hidden */ markSyncedWithParent(): void;
  24896. /** @hidden */
  24897. isSynchronizedWithParent(): boolean;
  24898. /** @hidden */
  24899. isSynchronized(): boolean;
  24900. /**
  24901. * Is this node ready to be used/rendered
  24902. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24903. * @return true if the node is ready
  24904. */
  24905. isReady(completeCheck?: boolean): boolean;
  24906. /**
  24907. * Is this node enabled?
  24908. * 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
  24909. * @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
  24910. * @return whether this node (and its parent) is enabled
  24911. */
  24912. isEnabled(checkAncestors?: boolean): boolean;
  24913. /** @hidden */
  24914. protected _syncParentEnabledState(): void;
  24915. /**
  24916. * Set the enabled state of this node
  24917. * @param value defines the new enabled state
  24918. */
  24919. setEnabled(value: boolean): void;
  24920. /**
  24921. * Is this node a descendant of the given node?
  24922. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24923. * @param ancestor defines the parent node to inspect
  24924. * @returns a boolean indicating if this node is a descendant of the given node
  24925. */
  24926. isDescendantOf(ancestor: Node): boolean;
  24927. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24928. /**
  24929. * Will return all nodes that have this node as ascendant
  24930. * @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
  24931. * @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
  24932. * @return all children nodes of all types
  24933. */
  24934. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24935. /**
  24936. * Get all child-meshes of this node
  24937. * @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)
  24938. * @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
  24939. * @returns an array of AbstractMesh
  24940. */
  24941. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24942. /**
  24943. * Get all direct children of this node
  24944. * @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
  24945. * @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)
  24946. * @returns an array of Node
  24947. */
  24948. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24949. /** @hidden */ setReady(state: boolean): void;
  24950. /**
  24951. * Get an animation by name
  24952. * @param name defines the name of the animation to look for
  24953. * @returns null if not found else the requested animation
  24954. */
  24955. getAnimationByName(name: string): Nullable<Animation>;
  24956. /**
  24957. * Creates an animation range for this node
  24958. * @param name defines the name of the range
  24959. * @param from defines the starting key
  24960. * @param to defines the end key
  24961. */
  24962. createAnimationRange(name: string, from: number, to: number): void;
  24963. /**
  24964. * Delete a specific animation range
  24965. * @param name defines the name of the range to delete
  24966. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24967. */
  24968. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24969. /**
  24970. * Get an animation range by name
  24971. * @param name defines the name of the animation range to look for
  24972. * @returns null if not found else the requested animation range
  24973. */
  24974. getAnimationRange(name: string): Nullable<AnimationRange>;
  24975. /**
  24976. * Gets the list of all animation ranges defined on this node
  24977. * @returns an array
  24978. */
  24979. getAnimationRanges(): Nullable<AnimationRange>[];
  24980. /**
  24981. * Will start the animation sequence
  24982. * @param name defines the range frames for animation sequence
  24983. * @param loop defines if the animation should loop (false by default)
  24984. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24985. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24986. * @returns the object created for this animation. If range does not exist, it will return null
  24987. */
  24988. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24989. /**
  24990. * Serialize animation ranges into a JSON compatible object
  24991. * @returns serialization object
  24992. */
  24993. serializeAnimationRanges(): any;
  24994. /**
  24995. * Computes the world matrix of the node
  24996. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24997. * @returns the world matrix
  24998. */
  24999. computeWorldMatrix(force?: boolean): Matrix;
  25000. /**
  25001. * Releases resources associated with this node.
  25002. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25003. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25004. */
  25005. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25006. /**
  25007. * Parse animation range data from a serialization object and store them into a given node
  25008. * @param node defines where to store the animation ranges
  25009. * @param parsedNode defines the serialization object to read data from
  25010. * @param scene defines the hosting scene
  25011. */
  25012. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25013. /**
  25014. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25015. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25016. * @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
  25017. * @returns the new bounding vectors
  25018. */
  25019. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25020. min: Vector3;
  25021. max: Vector3;
  25022. };
  25023. }
  25024. }
  25025. declare module BABYLON {
  25026. /**
  25027. * @hidden
  25028. */
  25029. export class _IAnimationState {
  25030. key: number;
  25031. repeatCount: number;
  25032. workValue?: any;
  25033. loopMode?: number;
  25034. offsetValue?: any;
  25035. highLimitValue?: any;
  25036. }
  25037. /**
  25038. * Class used to store any kind of animation
  25039. */
  25040. export class Animation {
  25041. /**Name of the animation */
  25042. name: string;
  25043. /**Property to animate */
  25044. targetProperty: string;
  25045. /**The frames per second of the animation */
  25046. framePerSecond: number;
  25047. /**The data type of the animation */
  25048. dataType: number;
  25049. /**The loop mode of the animation */
  25050. loopMode?: number | undefined;
  25051. /**Specifies if blending should be enabled */
  25052. enableBlending?: boolean | undefined;
  25053. /**
  25054. * Use matrix interpolation instead of using direct key value when animating matrices
  25055. */
  25056. static AllowMatricesInterpolation: boolean;
  25057. /**
  25058. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25059. */
  25060. static AllowMatrixDecomposeForInterpolation: boolean;
  25061. /**
  25062. * Stores the key frames of the animation
  25063. */
  25064. private _keys;
  25065. /**
  25066. * Stores the easing function of the animation
  25067. */
  25068. private _easingFunction;
  25069. /**
  25070. * @hidden Internal use only
  25071. */ runtimeAnimations: RuntimeAnimation[];
  25072. /**
  25073. * The set of event that will be linked to this animation
  25074. */
  25075. private _events;
  25076. /**
  25077. * Stores an array of target property paths
  25078. */
  25079. targetPropertyPath: string[];
  25080. /**
  25081. * Stores the blending speed of the animation
  25082. */
  25083. blendingSpeed: number;
  25084. /**
  25085. * Stores the animation ranges for the animation
  25086. */
  25087. private _ranges;
  25088. /**
  25089. * @hidden Internal use
  25090. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25091. /**
  25092. * Sets up an animation
  25093. * @param property The property to animate
  25094. * @param animationType The animation type to apply
  25095. * @param framePerSecond The frames per second of the animation
  25096. * @param easingFunction The easing function used in the animation
  25097. * @returns The created animation
  25098. */
  25099. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25100. /**
  25101. * Create and start an animation on a node
  25102. * @param name defines the name of the global animation that will be run on all nodes
  25103. * @param node defines the root node where the animation will take place
  25104. * @param targetProperty defines property to animate
  25105. * @param framePerSecond defines the number of frame per second yo use
  25106. * @param totalFrame defines the number of frames in total
  25107. * @param from defines the initial value
  25108. * @param to defines the final value
  25109. * @param loopMode defines which loop mode you want to use (off by default)
  25110. * @param easingFunction defines the easing function to use (linear by default)
  25111. * @param onAnimationEnd defines the callback to call when animation end
  25112. * @returns the animatable created for this animation
  25113. */
  25114. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25115. /**
  25116. * Create and start an animation on a node and its descendants
  25117. * @param name defines the name of the global animation that will be run on all nodes
  25118. * @param node defines the root node where the animation will take place
  25119. * @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
  25120. * @param targetProperty defines property to animate
  25121. * @param framePerSecond defines the number of frame per second to use
  25122. * @param totalFrame defines the number of frames in total
  25123. * @param from defines the initial value
  25124. * @param to defines the final value
  25125. * @param loopMode defines which loop mode you want to use (off by default)
  25126. * @param easingFunction defines the easing function to use (linear by default)
  25127. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25128. * @returns the list of animatables created for all nodes
  25129. * @example https://www.babylonjs-playground.com/#MH0VLI
  25130. */
  25131. 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[]>;
  25132. /**
  25133. * Creates a new animation, merges it with the existing animations and starts it
  25134. * @param name Name of the animation
  25135. * @param node Node which contains the scene that begins the animations
  25136. * @param targetProperty Specifies which property to animate
  25137. * @param framePerSecond The frames per second of the animation
  25138. * @param totalFrame The total number of frames
  25139. * @param from The frame at the beginning of the animation
  25140. * @param to The frame at the end of the animation
  25141. * @param loopMode Specifies the loop mode of the animation
  25142. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25143. * @param onAnimationEnd Callback to run once the animation is complete
  25144. * @returns Nullable animation
  25145. */
  25146. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25147. /**
  25148. * Transition property of an host to the target Value
  25149. * @param property The property to transition
  25150. * @param targetValue The target Value of the property
  25151. * @param host The object where the property to animate belongs
  25152. * @param scene Scene used to run the animation
  25153. * @param frameRate Framerate (in frame/s) to use
  25154. * @param transition The transition type we want to use
  25155. * @param duration The duration of the animation, in milliseconds
  25156. * @param onAnimationEnd Callback trigger at the end of the animation
  25157. * @returns Nullable animation
  25158. */
  25159. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25160. /**
  25161. * Return the array of runtime animations currently using this animation
  25162. */
  25163. readonly runtimeAnimations: RuntimeAnimation[];
  25164. /**
  25165. * Specifies if any of the runtime animations are currently running
  25166. */
  25167. readonly hasRunningRuntimeAnimations: boolean;
  25168. /**
  25169. * Initializes the animation
  25170. * @param name Name of the animation
  25171. * @param targetProperty Property to animate
  25172. * @param framePerSecond The frames per second of the animation
  25173. * @param dataType The data type of the animation
  25174. * @param loopMode The loop mode of the animation
  25175. * @param enableBlending Specifies if blending should be enabled
  25176. */
  25177. constructor(
  25178. /**Name of the animation */
  25179. name: string,
  25180. /**Property to animate */
  25181. targetProperty: string,
  25182. /**The frames per second of the animation */
  25183. framePerSecond: number,
  25184. /**The data type of the animation */
  25185. dataType: number,
  25186. /**The loop mode of the animation */
  25187. loopMode?: number | undefined,
  25188. /**Specifies if blending should be enabled */
  25189. enableBlending?: boolean | undefined);
  25190. /**
  25191. * Converts the animation to a string
  25192. * @param fullDetails support for multiple levels of logging within scene loading
  25193. * @returns String form of the animation
  25194. */
  25195. toString(fullDetails?: boolean): string;
  25196. /**
  25197. * Add an event to this animation
  25198. * @param event Event to add
  25199. */
  25200. addEvent(event: AnimationEvent): void;
  25201. /**
  25202. * Remove all events found at the given frame
  25203. * @param frame The frame to remove events from
  25204. */
  25205. removeEvents(frame: number): void;
  25206. /**
  25207. * Retrieves all the events from the animation
  25208. * @returns Events from the animation
  25209. */
  25210. getEvents(): AnimationEvent[];
  25211. /**
  25212. * Creates an animation range
  25213. * @param name Name of the animation range
  25214. * @param from Starting frame of the animation range
  25215. * @param to Ending frame of the animation
  25216. */
  25217. createRange(name: string, from: number, to: number): void;
  25218. /**
  25219. * Deletes an animation range by name
  25220. * @param name Name of the animation range to delete
  25221. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25222. */
  25223. deleteRange(name: string, deleteFrames?: boolean): void;
  25224. /**
  25225. * Gets the animation range by name, or null if not defined
  25226. * @param name Name of the animation range
  25227. * @returns Nullable animation range
  25228. */
  25229. getRange(name: string): Nullable<AnimationRange>;
  25230. /**
  25231. * Gets the key frames from the animation
  25232. * @returns The key frames of the animation
  25233. */
  25234. getKeys(): Array<IAnimationKey>;
  25235. /**
  25236. * Gets the highest frame rate of the animation
  25237. * @returns Highest frame rate of the animation
  25238. */
  25239. getHighestFrame(): number;
  25240. /**
  25241. * Gets the easing function of the animation
  25242. * @returns Easing function of the animation
  25243. */
  25244. getEasingFunction(): IEasingFunction;
  25245. /**
  25246. * Sets the easing function of the animation
  25247. * @param easingFunction A custom mathematical formula for animation
  25248. */
  25249. setEasingFunction(easingFunction: EasingFunction): void;
  25250. /**
  25251. * Interpolates a scalar linearly
  25252. * @param startValue Start value of the animation curve
  25253. * @param endValue End value of the animation curve
  25254. * @param gradient Scalar amount to interpolate
  25255. * @returns Interpolated scalar value
  25256. */
  25257. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25258. /**
  25259. * Interpolates a scalar cubically
  25260. * @param startValue Start value of the animation curve
  25261. * @param outTangent End tangent of the animation
  25262. * @param endValue End value of the animation curve
  25263. * @param inTangent Start tangent of the animation curve
  25264. * @param gradient Scalar amount to interpolate
  25265. * @returns Interpolated scalar value
  25266. */
  25267. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25268. /**
  25269. * Interpolates a quaternion using a spherical linear interpolation
  25270. * @param startValue Start value of the animation curve
  25271. * @param endValue End value of the animation curve
  25272. * @param gradient Scalar amount to interpolate
  25273. * @returns Interpolated quaternion value
  25274. */
  25275. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25276. /**
  25277. * Interpolates a quaternion cubically
  25278. * @param startValue Start value of the animation curve
  25279. * @param outTangent End tangent of the animation curve
  25280. * @param endValue End value of the animation curve
  25281. * @param inTangent Start tangent of the animation curve
  25282. * @param gradient Scalar amount to interpolate
  25283. * @returns Interpolated quaternion value
  25284. */
  25285. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25286. /**
  25287. * Interpolates a Vector3 linearl
  25288. * @param startValue Start value of the animation curve
  25289. * @param endValue End value of the animation curve
  25290. * @param gradient Scalar amount to interpolate
  25291. * @returns Interpolated scalar value
  25292. */
  25293. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25294. /**
  25295. * Interpolates a Vector3 cubically
  25296. * @param startValue Start value of the animation curve
  25297. * @param outTangent End tangent of the animation
  25298. * @param endValue End value of the animation curve
  25299. * @param inTangent Start tangent of the animation curve
  25300. * @param gradient Scalar amount to interpolate
  25301. * @returns InterpolatedVector3 value
  25302. */
  25303. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25304. /**
  25305. * Interpolates a Vector2 linearly
  25306. * @param startValue Start value of the animation curve
  25307. * @param endValue End value of the animation curve
  25308. * @param gradient Scalar amount to interpolate
  25309. * @returns Interpolated Vector2 value
  25310. */
  25311. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25312. /**
  25313. * Interpolates a Vector2 cubically
  25314. * @param startValue Start value of the animation curve
  25315. * @param outTangent End tangent of the animation
  25316. * @param endValue End value of the animation curve
  25317. * @param inTangent Start tangent of the animation curve
  25318. * @param gradient Scalar amount to interpolate
  25319. * @returns Interpolated Vector2 value
  25320. */
  25321. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25322. /**
  25323. * Interpolates a size linearly
  25324. * @param startValue Start value of the animation curve
  25325. * @param endValue End value of the animation curve
  25326. * @param gradient Scalar amount to interpolate
  25327. * @returns Interpolated Size value
  25328. */
  25329. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25330. /**
  25331. * Interpolates a Color3 linearly
  25332. * @param startValue Start value of the animation curve
  25333. * @param endValue End value of the animation curve
  25334. * @param gradient Scalar amount to interpolate
  25335. * @returns Interpolated Color3 value
  25336. */
  25337. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25338. /**
  25339. * @hidden Internal use only
  25340. */ getKeyValue(value: any): any;
  25341. /**
  25342. * @hidden Internal use only
  25343. */ interpolate(currentFrame: number, state: _IAnimationState): any;
  25344. /**
  25345. * Defines the function to use to interpolate matrices
  25346. * @param startValue defines the start matrix
  25347. * @param endValue defines the end matrix
  25348. * @param gradient defines the gradient between both matrices
  25349. * @param result defines an optional target matrix where to store the interpolation
  25350. * @returns the interpolated matrix
  25351. */
  25352. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25353. /**
  25354. * Makes a copy of the animation
  25355. * @returns Cloned animation
  25356. */
  25357. clone(): Animation;
  25358. /**
  25359. * Sets the key frames of the animation
  25360. * @param values The animation key frames to set
  25361. */
  25362. setKeys(values: Array<IAnimationKey>): void;
  25363. /**
  25364. * Serializes the animation to an object
  25365. * @returns Serialized object
  25366. */
  25367. serialize(): any;
  25368. /**
  25369. * Float animation type
  25370. */
  25371. private static _ANIMATIONTYPE_FLOAT;
  25372. /**
  25373. * Vector3 animation type
  25374. */
  25375. private static _ANIMATIONTYPE_VECTOR3;
  25376. /**
  25377. * Quaternion animation type
  25378. */
  25379. private static _ANIMATIONTYPE_QUATERNION;
  25380. /**
  25381. * Matrix animation type
  25382. */
  25383. private static _ANIMATIONTYPE_MATRIX;
  25384. /**
  25385. * Color3 animation type
  25386. */
  25387. private static _ANIMATIONTYPE_COLOR3;
  25388. /**
  25389. * Vector2 animation type
  25390. */
  25391. private static _ANIMATIONTYPE_VECTOR2;
  25392. /**
  25393. * Size animation type
  25394. */
  25395. private static _ANIMATIONTYPE_SIZE;
  25396. /**
  25397. * Relative Loop Mode
  25398. */
  25399. private static _ANIMATIONLOOPMODE_RELATIVE;
  25400. /**
  25401. * Cycle Loop Mode
  25402. */
  25403. private static _ANIMATIONLOOPMODE_CYCLE;
  25404. /**
  25405. * Constant Loop Mode
  25406. */
  25407. private static _ANIMATIONLOOPMODE_CONSTANT;
  25408. /**
  25409. * Get the float animation type
  25410. */
  25411. static readonly ANIMATIONTYPE_FLOAT: number;
  25412. /**
  25413. * Get the Vector3 animation type
  25414. */
  25415. static readonly ANIMATIONTYPE_VECTOR3: number;
  25416. /**
  25417. * Get the Vector2 animation type
  25418. */
  25419. static readonly ANIMATIONTYPE_VECTOR2: number;
  25420. /**
  25421. * Get the Size animation type
  25422. */
  25423. static readonly ANIMATIONTYPE_SIZE: number;
  25424. /**
  25425. * Get the Quaternion animation type
  25426. */
  25427. static readonly ANIMATIONTYPE_QUATERNION: number;
  25428. /**
  25429. * Get the Matrix animation type
  25430. */
  25431. static readonly ANIMATIONTYPE_MATRIX: number;
  25432. /**
  25433. * Get the Color3 animation type
  25434. */
  25435. static readonly ANIMATIONTYPE_COLOR3: number;
  25436. /**
  25437. * Get the Relative Loop Mode
  25438. */
  25439. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25440. /**
  25441. * Get the Cycle Loop Mode
  25442. */
  25443. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25444. /**
  25445. * Get the Constant Loop Mode
  25446. */
  25447. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25448. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25449. /**
  25450. * Parses an animation object and creates an animation
  25451. * @param parsedAnimation Parsed animation object
  25452. * @returns Animation object
  25453. */
  25454. static Parse(parsedAnimation: any): Animation;
  25455. /**
  25456. * Appends the serialized animations from the source animations
  25457. * @param source Source containing the animations
  25458. * @param destination Target to store the animations
  25459. */
  25460. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25461. }
  25462. }
  25463. declare module BABYLON {
  25464. /**
  25465. * Base class of all the textures in babylon.
  25466. * It groups all the common properties the materials, post process, lights... might need
  25467. * in order to make a correct use of the texture.
  25468. */
  25469. export class BaseTexture implements IAnimatable {
  25470. /**
  25471. * Default anisotropic filtering level for the application.
  25472. * It is set to 4 as a good tradeoff between perf and quality.
  25473. */
  25474. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25475. /**
  25476. * Gets or sets the unique id of the texture
  25477. */
  25478. uniqueId: number;
  25479. /**
  25480. * Define the name of the texture.
  25481. */
  25482. name: string;
  25483. /**
  25484. * Gets or sets an object used to store user defined information.
  25485. */
  25486. metadata: any;
  25487. /**
  25488. * For internal use only. Please do not use.
  25489. */
  25490. reservedDataStore: any;
  25491. private _hasAlpha;
  25492. /**
  25493. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25494. */
  25495. hasAlpha: boolean;
  25496. /**
  25497. * Defines if the alpha value should be determined via the rgb values.
  25498. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25499. */
  25500. getAlphaFromRGB: boolean;
  25501. /**
  25502. * Intensity or strength of the texture.
  25503. * It is commonly used by materials to fine tune the intensity of the texture
  25504. */
  25505. level: number;
  25506. /**
  25507. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25508. * This is part of the texture as textures usually maps to one uv set.
  25509. */
  25510. coordinatesIndex: number;
  25511. private _coordinatesMode;
  25512. /**
  25513. * How a texture is mapped.
  25514. *
  25515. * | Value | Type | Description |
  25516. * | ----- | ----------------------------------- | ----------- |
  25517. * | 0 | EXPLICIT_MODE | |
  25518. * | 1 | SPHERICAL_MODE | |
  25519. * | 2 | PLANAR_MODE | |
  25520. * | 3 | CUBIC_MODE | |
  25521. * | 4 | PROJECTION_MODE | |
  25522. * | 5 | SKYBOX_MODE | |
  25523. * | 6 | INVCUBIC_MODE | |
  25524. * | 7 | EQUIRECTANGULAR_MODE | |
  25525. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25526. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25527. */
  25528. coordinatesMode: number;
  25529. /**
  25530. * | Value | Type | Description |
  25531. * | ----- | ------------------ | ----------- |
  25532. * | 0 | CLAMP_ADDRESSMODE | |
  25533. * | 1 | WRAP_ADDRESSMODE | |
  25534. * | 2 | MIRROR_ADDRESSMODE | |
  25535. */
  25536. wrapU: number;
  25537. /**
  25538. * | Value | Type | Description |
  25539. * | ----- | ------------------ | ----------- |
  25540. * | 0 | CLAMP_ADDRESSMODE | |
  25541. * | 1 | WRAP_ADDRESSMODE | |
  25542. * | 2 | MIRROR_ADDRESSMODE | |
  25543. */
  25544. wrapV: number;
  25545. /**
  25546. * | Value | Type | Description |
  25547. * | ----- | ------------------ | ----------- |
  25548. * | 0 | CLAMP_ADDRESSMODE | |
  25549. * | 1 | WRAP_ADDRESSMODE | |
  25550. * | 2 | MIRROR_ADDRESSMODE | |
  25551. */
  25552. wrapR: number;
  25553. /**
  25554. * With compliant hardware and browser (supporting anisotropic filtering)
  25555. * this defines the level of anisotropic filtering in the texture.
  25556. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25557. */
  25558. anisotropicFilteringLevel: number;
  25559. /**
  25560. * Define if the texture is a cube texture or if false a 2d texture.
  25561. */
  25562. isCube: boolean;
  25563. /**
  25564. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25565. */
  25566. is3D: boolean;
  25567. /**
  25568. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25569. * HDR texture are usually stored in linear space.
  25570. * This only impacts the PBR and Background materials
  25571. */
  25572. gammaSpace: boolean;
  25573. /**
  25574. * Gets whether or not the texture contains RGBD data.
  25575. */
  25576. readonly isRGBD: boolean;
  25577. /**
  25578. * Is Z inverted in the texture (useful in a cube texture).
  25579. */
  25580. invertZ: boolean;
  25581. /**
  25582. * Are mip maps generated for this texture or not.
  25583. */
  25584. readonly noMipmap: boolean;
  25585. /**
  25586. * @hidden
  25587. */
  25588. lodLevelInAlpha: boolean;
  25589. /**
  25590. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25591. */
  25592. lodGenerationOffset: number;
  25593. /**
  25594. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25595. */
  25596. lodGenerationScale: number;
  25597. /**
  25598. * Define if the texture is a render target.
  25599. */
  25600. isRenderTarget: boolean;
  25601. /**
  25602. * Define the unique id of the texture in the scene.
  25603. */
  25604. readonly uid: string;
  25605. /**
  25606. * Return a string representation of the texture.
  25607. * @returns the texture as a string
  25608. */
  25609. toString(): string;
  25610. /**
  25611. * Get the class name of the texture.
  25612. * @returns "BaseTexture"
  25613. */
  25614. getClassName(): string;
  25615. /**
  25616. * Define the list of animation attached to the texture.
  25617. */
  25618. animations: Animation[];
  25619. /**
  25620. * An event triggered when the texture is disposed.
  25621. */
  25622. onDisposeObservable: Observable<BaseTexture>;
  25623. private _onDisposeObserver;
  25624. /**
  25625. * Callback triggered when the texture has been disposed.
  25626. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25627. */
  25628. onDispose: () => void;
  25629. /**
  25630. * Define the current state of the loading sequence when in delayed load mode.
  25631. */
  25632. delayLoadState: number;
  25633. private _scene;
  25634. /** @hidden */ texture: Nullable<InternalTexture>;
  25635. private _uid;
  25636. /**
  25637. * Define if the texture is preventinga material to render or not.
  25638. * If not and the texture is not ready, the engine will use a default black texture instead.
  25639. */
  25640. readonly isBlocking: boolean;
  25641. /**
  25642. * Instantiates a new BaseTexture.
  25643. * Base class of all the textures in babylon.
  25644. * It groups all the common properties the materials, post process, lights... might need
  25645. * in order to make a correct use of the texture.
  25646. * @param scene Define the scene the texture blongs to
  25647. */
  25648. constructor(scene: Nullable<Scene>);
  25649. /**
  25650. * Get the scene the texture belongs to.
  25651. * @returns the scene or null if undefined
  25652. */
  25653. getScene(): Nullable<Scene>;
  25654. /**
  25655. * Get the texture transform matrix used to offset tile the texture for istance.
  25656. * @returns the transformation matrix
  25657. */
  25658. getTextureMatrix(): Matrix;
  25659. /**
  25660. * Get the texture reflection matrix used to rotate/transform the reflection.
  25661. * @returns the reflection matrix
  25662. */
  25663. getReflectionTextureMatrix(): Matrix;
  25664. /**
  25665. * Get the underlying lower level texture from Babylon.
  25666. * @returns the insternal texture
  25667. */
  25668. getInternalTexture(): Nullable<InternalTexture>;
  25669. /**
  25670. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25671. * @returns true if ready or not blocking
  25672. */
  25673. isReadyOrNotBlocking(): boolean;
  25674. /**
  25675. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25676. * @returns true if fully ready
  25677. */
  25678. isReady(): boolean;
  25679. private _cachedSize;
  25680. /**
  25681. * Get the size of the texture.
  25682. * @returns the texture size.
  25683. */
  25684. getSize(): ISize;
  25685. /**
  25686. * Get the base size of the texture.
  25687. * It can be different from the size if the texture has been resized for POT for instance
  25688. * @returns the base size
  25689. */
  25690. getBaseSize(): ISize;
  25691. /**
  25692. * Update the sampling mode of the texture.
  25693. * Default is Trilinear mode.
  25694. *
  25695. * | Value | Type | Description |
  25696. * | ----- | ------------------ | ----------- |
  25697. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25698. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25699. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25700. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25701. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25702. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25703. * | 7 | NEAREST_LINEAR | |
  25704. * | 8 | NEAREST_NEAREST | |
  25705. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25706. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25707. * | 11 | LINEAR_LINEAR | |
  25708. * | 12 | LINEAR_NEAREST | |
  25709. *
  25710. * > _mag_: magnification filter (close to the viewer)
  25711. * > _min_: minification filter (far from the viewer)
  25712. * > _mip_: filter used between mip map levels
  25713. *@param samplingMode Define the new sampling mode of the texture
  25714. */
  25715. updateSamplingMode(samplingMode: number): void;
  25716. /**
  25717. * Scales the texture if is `canRescale()`
  25718. * @param ratio the resize factor we want to use to rescale
  25719. */
  25720. scale(ratio: number): void;
  25721. /**
  25722. * Get if the texture can rescale.
  25723. */
  25724. readonly canRescale: boolean;
  25725. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25726. /** @hidden */ rebuild(): void;
  25727. /**
  25728. * Triggers the load sequence in delayed load mode.
  25729. */
  25730. delayLoad(): void;
  25731. /**
  25732. * Clones the texture.
  25733. * @returns the cloned texture
  25734. */
  25735. clone(): Nullable<BaseTexture>;
  25736. /**
  25737. * Get the texture underlying type (INT, FLOAT...)
  25738. */
  25739. readonly textureType: number;
  25740. /**
  25741. * Get the texture underlying format (RGB, RGBA...)
  25742. */
  25743. readonly textureFormat: number;
  25744. /**
  25745. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25746. * This will returns an RGBA array buffer containing either in values (0-255) or
  25747. * float values (0-1) depending of the underlying buffer type.
  25748. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25749. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25750. * @param buffer defines a user defined buffer to fill with data (can be null)
  25751. * @returns The Array buffer containing the pixels data.
  25752. */
  25753. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25754. /**
  25755. * Release and destroy the underlying lower level texture aka internalTexture.
  25756. */
  25757. releaseInternalTexture(): void;
  25758. /**
  25759. * Get the polynomial representation of the texture data.
  25760. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25761. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25762. */
  25763. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25764. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  25765. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  25766. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  25767. /**
  25768. * Dispose the texture and release its associated resources.
  25769. */
  25770. dispose(): void;
  25771. /**
  25772. * Serialize the texture into a JSON representation that can be parsed later on.
  25773. * @returns the JSON representation of the texture
  25774. */
  25775. serialize(): any;
  25776. /**
  25777. * Helper function to be called back once a list of texture contains only ready textures.
  25778. * @param textures Define the list of textures to wait for
  25779. * @param callback Define the callback triggered once the entire list will be ready
  25780. */
  25781. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25782. }
  25783. }
  25784. declare module BABYLON {
  25785. /**
  25786. * Uniform buffer objects.
  25787. *
  25788. * Handles blocks of uniform on the GPU.
  25789. *
  25790. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25791. *
  25792. * For more information, please refer to :
  25793. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25794. */
  25795. export class UniformBuffer {
  25796. private _engine;
  25797. private _buffer;
  25798. private _data;
  25799. private _bufferData;
  25800. private _dynamic?;
  25801. private _uniformLocations;
  25802. private _uniformSizes;
  25803. private _uniformLocationPointer;
  25804. private _needSync;
  25805. private _noUBO;
  25806. private _currentEffect;
  25807. private static _MAX_UNIFORM_SIZE;
  25808. private static _tempBuffer;
  25809. /**
  25810. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25811. * This is dynamic to allow compat with webgl 1 and 2.
  25812. * You will need to pass the name of the uniform as well as the value.
  25813. */
  25814. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25815. /**
  25816. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25817. * This is dynamic to allow compat with webgl 1 and 2.
  25818. * You will need to pass the name of the uniform as well as the value.
  25819. */
  25820. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25821. /**
  25822. * Lambda to Update a single float in a uniform buffer.
  25823. * This is dynamic to allow compat with webgl 1 and 2.
  25824. * You will need to pass the name of the uniform as well as the value.
  25825. */
  25826. updateFloat: (name: string, x: number) => void;
  25827. /**
  25828. * Lambda to Update a vec2 of float in a uniform buffer.
  25829. * This is dynamic to allow compat with webgl 1 and 2.
  25830. * You will need to pass the name of the uniform as well as the value.
  25831. */
  25832. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25833. /**
  25834. * Lambda to Update a vec3 of float in a uniform buffer.
  25835. * This is dynamic to allow compat with webgl 1 and 2.
  25836. * You will need to pass the name of the uniform as well as the value.
  25837. */
  25838. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25839. /**
  25840. * Lambda to Update a vec4 of float in a uniform buffer.
  25841. * This is dynamic to allow compat with webgl 1 and 2.
  25842. * You will need to pass the name of the uniform as well as the value.
  25843. */
  25844. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25845. /**
  25846. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25847. * This is dynamic to allow compat with webgl 1 and 2.
  25848. * You will need to pass the name of the uniform as well as the value.
  25849. */
  25850. updateMatrix: (name: string, mat: Matrix) => void;
  25851. /**
  25852. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25853. * This is dynamic to allow compat with webgl 1 and 2.
  25854. * You will need to pass the name of the uniform as well as the value.
  25855. */
  25856. updateVector3: (name: string, vector: Vector3) => void;
  25857. /**
  25858. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25859. * This is dynamic to allow compat with webgl 1 and 2.
  25860. * You will need to pass the name of the uniform as well as the value.
  25861. */
  25862. updateVector4: (name: string, vector: Vector4) => void;
  25863. /**
  25864. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25865. * This is dynamic to allow compat with webgl 1 and 2.
  25866. * You will need to pass the name of the uniform as well as the value.
  25867. */
  25868. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25869. /**
  25870. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25871. * This is dynamic to allow compat with webgl 1 and 2.
  25872. * You will need to pass the name of the uniform as well as the value.
  25873. */
  25874. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25875. /**
  25876. * Instantiates a new Uniform buffer objects.
  25877. *
  25878. * Handles blocks of uniform on the GPU.
  25879. *
  25880. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25881. *
  25882. * For more information, please refer to :
  25883. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25884. * @param engine Define the engine the buffer is associated with
  25885. * @param data Define the data contained in the buffer
  25886. * @param dynamic Define if the buffer is updatable
  25887. */
  25888. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25889. /**
  25890. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25891. * or just falling back on setUniformXXX calls.
  25892. */
  25893. readonly useUbo: boolean;
  25894. /**
  25895. * Indicates if the WebGL underlying uniform buffer is in sync
  25896. * with the javascript cache data.
  25897. */
  25898. readonly isSync: boolean;
  25899. /**
  25900. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25901. * Also, a dynamic UniformBuffer will disable cache verification and always
  25902. * update the underlying WebGL uniform buffer to the GPU.
  25903. * @returns if Dynamic, otherwise false
  25904. */
  25905. isDynamic(): boolean;
  25906. /**
  25907. * The data cache on JS side.
  25908. * @returns the underlying data as a float array
  25909. */
  25910. getData(): Float32Array;
  25911. /**
  25912. * The underlying WebGL Uniform buffer.
  25913. * @returns the webgl buffer
  25914. */
  25915. getBuffer(): Nullable<DataBuffer>;
  25916. /**
  25917. * std140 layout specifies how to align data within an UBO structure.
  25918. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25919. * for specs.
  25920. */
  25921. private _fillAlignment;
  25922. /**
  25923. * Adds an uniform in the buffer.
  25924. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25925. * for the layout to be correct !
  25926. * @param name Name of the uniform, as used in the uniform block in the shader.
  25927. * @param size Data size, or data directly.
  25928. */
  25929. addUniform(name: string, size: number | number[]): void;
  25930. /**
  25931. * Adds a Matrix 4x4 to the uniform buffer.
  25932. * @param name Name of the uniform, as used in the uniform block in the shader.
  25933. * @param mat A 4x4 matrix.
  25934. */
  25935. addMatrix(name: string, mat: Matrix): void;
  25936. /**
  25937. * Adds a vec2 to the uniform buffer.
  25938. * @param name Name of the uniform, as used in the uniform block in the shader.
  25939. * @param x Define the x component value of the vec2
  25940. * @param y Define the y component value of the vec2
  25941. */
  25942. addFloat2(name: string, x: number, y: number): void;
  25943. /**
  25944. * Adds a vec3 to the uniform buffer.
  25945. * @param name Name of the uniform, as used in the uniform block in the shader.
  25946. * @param x Define the x component value of the vec3
  25947. * @param y Define the y component value of the vec3
  25948. * @param z Define the z component value of the vec3
  25949. */
  25950. addFloat3(name: string, x: number, y: number, z: number): void;
  25951. /**
  25952. * Adds a vec3 to the uniform buffer.
  25953. * @param name Name of the uniform, as used in the uniform block in the shader.
  25954. * @param color Define the vec3 from a Color
  25955. */
  25956. addColor3(name: string, color: Color3): void;
  25957. /**
  25958. * Adds a vec4 to the uniform buffer.
  25959. * @param name Name of the uniform, as used in the uniform block in the shader.
  25960. * @param color Define the rgb components from a Color
  25961. * @param alpha Define the a component of the vec4
  25962. */
  25963. addColor4(name: string, color: Color3, alpha: number): void;
  25964. /**
  25965. * Adds a vec3 to the uniform buffer.
  25966. * @param name Name of the uniform, as used in the uniform block in the shader.
  25967. * @param vector Define the vec3 components from a Vector
  25968. */
  25969. addVector3(name: string, vector: Vector3): void;
  25970. /**
  25971. * Adds a Matrix 3x3 to the uniform buffer.
  25972. * @param name Name of the uniform, as used in the uniform block in the shader.
  25973. */
  25974. addMatrix3x3(name: string): void;
  25975. /**
  25976. * Adds a Matrix 2x2 to the uniform buffer.
  25977. * @param name Name of the uniform, as used in the uniform block in the shader.
  25978. */
  25979. addMatrix2x2(name: string): void;
  25980. /**
  25981. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25982. */
  25983. create(): void;
  25984. /** @hidden */ rebuild(): void;
  25985. /**
  25986. * Updates the WebGL Uniform Buffer on the GPU.
  25987. * If the `dynamic` flag is set to true, no cache comparison is done.
  25988. * Otherwise, the buffer will be updated only if the cache differs.
  25989. */
  25990. update(): void;
  25991. /**
  25992. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25993. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25994. * @param data Define the flattened data
  25995. * @param size Define the size of the data.
  25996. */
  25997. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25998. private _updateMatrix3x3ForUniform;
  25999. private _updateMatrix3x3ForEffect;
  26000. private _updateMatrix2x2ForEffect;
  26001. private _updateMatrix2x2ForUniform;
  26002. private _updateFloatForEffect;
  26003. private _updateFloatForUniform;
  26004. private _updateFloat2ForEffect;
  26005. private _updateFloat2ForUniform;
  26006. private _updateFloat3ForEffect;
  26007. private _updateFloat3ForUniform;
  26008. private _updateFloat4ForEffect;
  26009. private _updateFloat4ForUniform;
  26010. private _updateMatrixForEffect;
  26011. private _updateMatrixForUniform;
  26012. private _updateVector3ForEffect;
  26013. private _updateVector3ForUniform;
  26014. private _updateVector4ForEffect;
  26015. private _updateVector4ForUniform;
  26016. private _updateColor3ForEffect;
  26017. private _updateColor3ForUniform;
  26018. private _updateColor4ForEffect;
  26019. private _updateColor4ForUniform;
  26020. /**
  26021. * Sets a sampler uniform on the effect.
  26022. * @param name Define the name of the sampler.
  26023. * @param texture Define the texture to set in the sampler
  26024. */
  26025. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26026. /**
  26027. * Directly updates the value of the uniform in the cache AND on the GPU.
  26028. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26029. * @param data Define the flattened data
  26030. */
  26031. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26032. /**
  26033. * Binds this uniform buffer to an effect.
  26034. * @param effect Define the effect to bind the buffer to
  26035. * @param name Name of the uniform block in the shader.
  26036. */
  26037. bindToEffect(effect: Effect, name: string): void;
  26038. /**
  26039. * Disposes the uniform buffer.
  26040. */
  26041. dispose(): void;
  26042. }
  26043. }
  26044. declare module BABYLON {
  26045. /**
  26046. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26048. */
  26049. export class Analyser {
  26050. /**
  26051. * Gets or sets the smoothing
  26052. * @ignorenaming
  26053. */
  26054. SMOOTHING: number;
  26055. /**
  26056. * Gets or sets the FFT table size
  26057. * @ignorenaming
  26058. */
  26059. FFT_SIZE: number;
  26060. /**
  26061. * Gets or sets the bar graph amplitude
  26062. * @ignorenaming
  26063. */
  26064. BARGRAPHAMPLITUDE: number;
  26065. /**
  26066. * Gets or sets the position of the debug canvas
  26067. * @ignorenaming
  26068. */
  26069. DEBUGCANVASPOS: {
  26070. x: number;
  26071. y: number;
  26072. };
  26073. /**
  26074. * Gets or sets the debug canvas size
  26075. * @ignorenaming
  26076. */
  26077. DEBUGCANVASSIZE: {
  26078. width: number;
  26079. height: number;
  26080. };
  26081. private _byteFreqs;
  26082. private _byteTime;
  26083. private _floatFreqs;
  26084. private _webAudioAnalyser;
  26085. private _debugCanvas;
  26086. private _debugCanvasContext;
  26087. private _scene;
  26088. private _registerFunc;
  26089. private _audioEngine;
  26090. /**
  26091. * Creates a new analyser
  26092. * @param scene defines hosting scene
  26093. */
  26094. constructor(scene: Scene);
  26095. /**
  26096. * Get the number of data values you will have to play with for the visualization
  26097. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26098. * @returns a number
  26099. */
  26100. getFrequencyBinCount(): number;
  26101. /**
  26102. * Gets the current frequency data as a byte array
  26103. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26104. * @returns a Uint8Array
  26105. */
  26106. getByteFrequencyData(): Uint8Array;
  26107. /**
  26108. * Gets the current waveform as a byte array
  26109. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26110. * @returns a Uint8Array
  26111. */
  26112. getByteTimeDomainData(): Uint8Array;
  26113. /**
  26114. * Gets the current frequency data as a float array
  26115. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26116. * @returns a Float32Array
  26117. */
  26118. getFloatFrequencyData(): Float32Array;
  26119. /**
  26120. * Renders the debug canvas
  26121. */
  26122. drawDebugCanvas(): void;
  26123. /**
  26124. * Stops rendering the debug canvas and removes it
  26125. */
  26126. stopDebugCanvas(): void;
  26127. /**
  26128. * Connects two audio nodes
  26129. * @param inputAudioNode defines first node to connect
  26130. * @param outputAudioNode defines second node to connect
  26131. */
  26132. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26133. /**
  26134. * Releases all associated resources
  26135. */
  26136. dispose(): void;
  26137. }
  26138. }
  26139. declare module BABYLON {
  26140. /**
  26141. * This represents an audio engine and it is responsible
  26142. * to play, synchronize and analyse sounds throughout the application.
  26143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26144. */
  26145. export interface IAudioEngine extends IDisposable {
  26146. /**
  26147. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26148. */
  26149. readonly canUseWebAudio: boolean;
  26150. /**
  26151. * Gets the current AudioContext if available.
  26152. */
  26153. readonly audioContext: Nullable<AudioContext>;
  26154. /**
  26155. * The master gain node defines the global audio volume of your audio engine.
  26156. */
  26157. readonly masterGain: GainNode;
  26158. /**
  26159. * Gets whether or not mp3 are supported by your browser.
  26160. */
  26161. readonly isMP3supported: boolean;
  26162. /**
  26163. * Gets whether or not ogg are supported by your browser.
  26164. */
  26165. readonly isOGGsupported: boolean;
  26166. /**
  26167. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26168. * @ignoreNaming
  26169. */
  26170. WarnedWebAudioUnsupported: boolean;
  26171. /**
  26172. * Defines if the audio engine relies on a custom unlocked button.
  26173. * In this case, the embedded button will not be displayed.
  26174. */
  26175. useCustomUnlockedButton: boolean;
  26176. /**
  26177. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26178. */
  26179. readonly unlocked: boolean;
  26180. /**
  26181. * Event raised when audio has been unlocked on the browser.
  26182. */
  26183. onAudioUnlockedObservable: Observable<AudioEngine>;
  26184. /**
  26185. * Event raised when audio has been locked on the browser.
  26186. */
  26187. onAudioLockedObservable: Observable<AudioEngine>;
  26188. /**
  26189. * Flags the audio engine in Locked state.
  26190. * This happens due to new browser policies preventing audio to autoplay.
  26191. */
  26192. lock(): void;
  26193. /**
  26194. * Unlocks the audio engine once a user action has been done on the dom.
  26195. * This is helpful to resume play once browser policies have been satisfied.
  26196. */
  26197. unlock(): void;
  26198. }
  26199. /**
  26200. * This represents the default audio engine used in babylon.
  26201. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26203. */
  26204. export class AudioEngine implements IAudioEngine {
  26205. private _audioContext;
  26206. private _audioContextInitialized;
  26207. private _muteButton;
  26208. private _hostElement;
  26209. /**
  26210. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26211. */
  26212. canUseWebAudio: boolean;
  26213. /**
  26214. * The master gain node defines the global audio volume of your audio engine.
  26215. */
  26216. masterGain: GainNode;
  26217. /**
  26218. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26219. * @ignoreNaming
  26220. */
  26221. WarnedWebAudioUnsupported: boolean;
  26222. /**
  26223. * Gets whether or not mp3 are supported by your browser.
  26224. */
  26225. isMP3supported: boolean;
  26226. /**
  26227. * Gets whether or not ogg are supported by your browser.
  26228. */
  26229. isOGGsupported: boolean;
  26230. /**
  26231. * Gets whether audio has been unlocked on the device.
  26232. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26233. * a user interaction has happened.
  26234. */
  26235. unlocked: boolean;
  26236. /**
  26237. * Defines if the audio engine relies on a custom unlocked button.
  26238. * In this case, the embedded button will not be displayed.
  26239. */
  26240. useCustomUnlockedButton: boolean;
  26241. /**
  26242. * Event raised when audio has been unlocked on the browser.
  26243. */
  26244. onAudioUnlockedObservable: Observable<AudioEngine>;
  26245. /**
  26246. * Event raised when audio has been locked on the browser.
  26247. */
  26248. onAudioLockedObservable: Observable<AudioEngine>;
  26249. /**
  26250. * Gets the current AudioContext if available.
  26251. */
  26252. readonly audioContext: Nullable<AudioContext>;
  26253. private _connectedAnalyser;
  26254. /**
  26255. * Instantiates a new audio engine.
  26256. *
  26257. * There should be only one per page as some browsers restrict the number
  26258. * of audio contexts you can create.
  26259. * @param hostElement defines the host element where to display the mute icon if necessary
  26260. */
  26261. constructor(hostElement?: Nullable<HTMLElement>);
  26262. /**
  26263. * Flags the audio engine in Locked state.
  26264. * This happens due to new browser policies preventing audio to autoplay.
  26265. */
  26266. lock(): void;
  26267. /**
  26268. * Unlocks the audio engine once a user action has been done on the dom.
  26269. * This is helpful to resume play once browser policies have been satisfied.
  26270. */
  26271. unlock(): void;
  26272. private _resumeAudioContext;
  26273. private _initializeAudioContext;
  26274. private _tryToRun;
  26275. private _triggerRunningState;
  26276. private _triggerSuspendedState;
  26277. private _displayMuteButton;
  26278. private _moveButtonToTopLeft;
  26279. private _onResize;
  26280. private _hideMuteButton;
  26281. /**
  26282. * Destroy and release the resources associated with the audio ccontext.
  26283. */
  26284. dispose(): void;
  26285. /**
  26286. * Gets the global volume sets on the master gain.
  26287. * @returns the global volume if set or -1 otherwise
  26288. */
  26289. getGlobalVolume(): number;
  26290. /**
  26291. * Sets the global volume of your experience (sets on the master gain).
  26292. * @param newVolume Defines the new global volume of the application
  26293. */
  26294. setGlobalVolume(newVolume: number): void;
  26295. /**
  26296. * Connect the audio engine to an audio analyser allowing some amazing
  26297. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26299. * @param analyser The analyser to connect to the engine
  26300. */
  26301. connectToAnalyser(analyser: Analyser): void;
  26302. }
  26303. }
  26304. declare module BABYLON {
  26305. /**
  26306. * Interface used to present a loading screen while loading a scene
  26307. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26308. */
  26309. export interface ILoadingScreen {
  26310. /**
  26311. * Function called to display the loading screen
  26312. */
  26313. displayLoadingUI: () => void;
  26314. /**
  26315. * Function called to hide the loading screen
  26316. */
  26317. hideLoadingUI: () => void;
  26318. /**
  26319. * Gets or sets the color to use for the background
  26320. */
  26321. loadingUIBackgroundColor: string;
  26322. /**
  26323. * Gets or sets the text to display while loading
  26324. */
  26325. loadingUIText: string;
  26326. }
  26327. /**
  26328. * Class used for the default loading screen
  26329. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26330. */
  26331. export class DefaultLoadingScreen implements ILoadingScreen {
  26332. private _renderingCanvas;
  26333. private _loadingText;
  26334. private _loadingDivBackgroundColor;
  26335. private _loadingDiv;
  26336. private _loadingTextDiv;
  26337. /**
  26338. * Creates a new default loading screen
  26339. * @param _renderingCanvas defines the canvas used to render the scene
  26340. * @param _loadingText defines the default text to display
  26341. * @param _loadingDivBackgroundColor defines the default background color
  26342. */
  26343. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26344. /**
  26345. * Function called to display the loading screen
  26346. */
  26347. displayLoadingUI(): void;
  26348. /**
  26349. * Function called to hide the loading screen
  26350. */
  26351. hideLoadingUI(): void;
  26352. /**
  26353. * Gets or sets the text to display while loading
  26354. */
  26355. loadingUIText: string;
  26356. /**
  26357. * Gets or sets the color to use for the background
  26358. */
  26359. loadingUIBackgroundColor: string;
  26360. private _resizeLoadingUI;
  26361. }
  26362. }
  26363. declare module BABYLON {
  26364. /** @hidden */
  26365. export class WebGLPipelineContext implements IPipelineContext {
  26366. engine: Engine;
  26367. program: Nullable<WebGLProgram>;
  26368. context?: WebGLRenderingContext;
  26369. vertexShader?: WebGLShader;
  26370. fragmentShader?: WebGLShader;
  26371. isParallelCompiled: boolean;
  26372. onCompiled?: () => void;
  26373. transformFeedback?: WebGLTransformFeedback | null;
  26374. readonly isAsync: boolean;
  26375. readonly isReady: boolean;
  26376. }
  26377. }
  26378. declare module BABYLON {
  26379. /** @hidden */
  26380. export class WebGLDataBuffer extends DataBuffer {
  26381. private _buffer;
  26382. constructor(resource: WebGLBuffer);
  26383. readonly underlyingResource: any;
  26384. }
  26385. }
  26386. declare module BABYLON {
  26387. /**
  26388. * Settings for finer control over video usage
  26389. */
  26390. export interface VideoTextureSettings {
  26391. /**
  26392. * Applies `autoplay` to video, if specified
  26393. */
  26394. autoPlay?: boolean;
  26395. /**
  26396. * Applies `loop` to video, if specified
  26397. */
  26398. loop?: boolean;
  26399. /**
  26400. * Automatically updates internal texture from video at every frame in the render loop
  26401. */
  26402. autoUpdateTexture: boolean;
  26403. /**
  26404. * Image src displayed during the video loading or until the user interacts with the video.
  26405. */
  26406. poster?: string;
  26407. }
  26408. /**
  26409. * If you want to display a video in your scene, this is the special texture for that.
  26410. * This special texture works similar to other textures, with the exception of a few parameters.
  26411. * @see https://doc.babylonjs.com/how_to/video_texture
  26412. */
  26413. export class VideoTexture extends Texture {
  26414. /**
  26415. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26416. */
  26417. readonly autoUpdateTexture: boolean;
  26418. /**
  26419. * The video instance used by the texture internally
  26420. */
  26421. readonly video: HTMLVideoElement;
  26422. private _onUserActionRequestedObservable;
  26423. /**
  26424. * Event triggerd when a dom action is required by the user to play the video.
  26425. * This happens due to recent changes in browser policies preventing video to auto start.
  26426. */
  26427. readonly onUserActionRequestedObservable: Observable<Texture>;
  26428. private _generateMipMaps;
  26429. private _engine;
  26430. private _stillImageCaptured;
  26431. private _displayingPosterTexture;
  26432. private _settings;
  26433. private _createInternalTextureOnEvent;
  26434. /**
  26435. * Creates a video texture.
  26436. * If you want to display a video in your scene, this is the special texture for that.
  26437. * This special texture works similar to other textures, with the exception of a few parameters.
  26438. * @see https://doc.babylonjs.com/how_to/video_texture
  26439. * @param name optional name, will detect from video source, if not defined
  26440. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26441. * @param scene is obviously the current scene.
  26442. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26443. * @param invertY is false by default but can be used to invert video on Y axis
  26444. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26445. * @param settings allows finer control over video usage
  26446. */
  26447. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26448. private _getName;
  26449. private _getVideo;
  26450. private _createInternalTexture;
  26451. private reset;
  26452. /**
  26453. * @hidden Internal method to initiate `update`.
  26454. */ rebuild(): void;
  26455. /**
  26456. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26457. */
  26458. update(): void;
  26459. /**
  26460. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26461. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26462. */
  26463. updateTexture(isVisible: boolean): void;
  26464. protected _updateInternalTexture: () => void;
  26465. /**
  26466. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26467. * @param url New url.
  26468. */
  26469. updateURL(url: string): void;
  26470. /**
  26471. * Dispose the texture and release its associated resources.
  26472. */
  26473. dispose(): void;
  26474. /**
  26475. * Creates a video texture straight from a stream.
  26476. * @param scene Define the scene the texture should be created in
  26477. * @param stream Define the stream the texture should be created from
  26478. * @returns The created video texture as a promise
  26479. */
  26480. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26481. /**
  26482. * Creates a video texture straight from your WebCam video feed.
  26483. * @param scene Define the scene the texture should be created in
  26484. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26485. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26486. * @returns The created video texture as a promise
  26487. */
  26488. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26489. minWidth: number;
  26490. maxWidth: number;
  26491. minHeight: number;
  26492. maxHeight: number;
  26493. deviceId: string;
  26494. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26495. /**
  26496. * Creates a video texture straight from your WebCam video feed.
  26497. * @param scene Define the scene the texture should be created in
  26498. * @param onReady Define a callback to triggered once the texture will be ready
  26499. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26500. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26501. */
  26502. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26503. minWidth: number;
  26504. maxWidth: number;
  26505. minHeight: number;
  26506. maxHeight: number;
  26507. deviceId: string;
  26508. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26509. }
  26510. }
  26511. declare module BABYLON {
  26512. /**
  26513. * Interface for attribute information associated with buffer instanciation
  26514. */
  26515. export class InstancingAttributeInfo {
  26516. /**
  26517. * Index/offset of the attribute in the vertex shader
  26518. */
  26519. index: number;
  26520. /**
  26521. * size of the attribute, 1, 2, 3 or 4
  26522. */
  26523. attributeSize: number;
  26524. /**
  26525. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26526. * default is FLOAT
  26527. */
  26528. attribyteType: number;
  26529. /**
  26530. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26531. */
  26532. normalized: boolean;
  26533. /**
  26534. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26535. */
  26536. offset: number;
  26537. /**
  26538. * Name of the GLSL attribute, for debugging purpose only
  26539. */
  26540. attributeName: string;
  26541. }
  26542. /**
  26543. * Define options used to create a depth texture
  26544. */
  26545. export class DepthTextureCreationOptions {
  26546. /** Specifies whether or not a stencil should be allocated in the texture */
  26547. generateStencil?: boolean;
  26548. /** Specifies whether or not bilinear filtering is enable on the texture */
  26549. bilinearFiltering?: boolean;
  26550. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26551. comparisonFunction?: number;
  26552. /** Specifies if the created texture is a cube texture */
  26553. isCube?: boolean;
  26554. }
  26555. /**
  26556. * Class used to describe the capabilities of the engine relatively to the current browser
  26557. */
  26558. export class EngineCapabilities {
  26559. /** Maximum textures units per fragment shader */
  26560. maxTexturesImageUnits: number;
  26561. /** Maximum texture units per vertex shader */
  26562. maxVertexTextureImageUnits: number;
  26563. /** Maximum textures units in the entire pipeline */
  26564. maxCombinedTexturesImageUnits: number;
  26565. /** Maximum texture size */
  26566. maxTextureSize: number;
  26567. /** Maximum cube texture size */
  26568. maxCubemapTextureSize: number;
  26569. /** Maximum render texture size */
  26570. maxRenderTextureSize: number;
  26571. /** Maximum number of vertex attributes */
  26572. maxVertexAttribs: number;
  26573. /** Maximum number of varyings */
  26574. maxVaryingVectors: number;
  26575. /** Maximum number of uniforms per vertex shader */
  26576. maxVertexUniformVectors: number;
  26577. /** Maximum number of uniforms per fragment shader */
  26578. maxFragmentUniformVectors: number;
  26579. /** Defines if standard derivates (dx/dy) are supported */
  26580. standardDerivatives: boolean;
  26581. /** Defines if s3tc texture compression is supported */
  26582. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26583. /** Defines if pvrtc texture compression is supported */
  26584. pvrtc: any;
  26585. /** Defines if etc1 texture compression is supported */
  26586. etc1: any;
  26587. /** Defines if etc2 texture compression is supported */
  26588. etc2: any;
  26589. /** Defines if astc texture compression is supported */
  26590. astc: any;
  26591. /** Defines if float textures are supported */
  26592. textureFloat: boolean;
  26593. /** Defines if vertex array objects are supported */
  26594. vertexArrayObject: boolean;
  26595. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26596. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26597. /** Gets the maximum level of anisotropy supported */
  26598. maxAnisotropy: number;
  26599. /** Defines if instancing is supported */
  26600. instancedArrays: boolean;
  26601. /** Defines if 32 bits indices are supported */
  26602. uintIndices: boolean;
  26603. /** Defines if high precision shaders are supported */
  26604. highPrecisionShaderSupported: boolean;
  26605. /** Defines if depth reading in the fragment shader is supported */
  26606. fragmentDepthSupported: boolean;
  26607. /** Defines if float texture linear filtering is supported*/
  26608. textureFloatLinearFiltering: boolean;
  26609. /** Defines if rendering to float textures is supported */
  26610. textureFloatRender: boolean;
  26611. /** Defines if half float textures are supported*/
  26612. textureHalfFloat: boolean;
  26613. /** Defines if half float texture linear filtering is supported*/
  26614. textureHalfFloatLinearFiltering: boolean;
  26615. /** Defines if rendering to half float textures is supported */
  26616. textureHalfFloatRender: boolean;
  26617. /** Defines if textureLOD shader command is supported */
  26618. textureLOD: boolean;
  26619. /** Defines if draw buffers extension is supported */
  26620. drawBuffersExtension: boolean;
  26621. /** Defines if depth textures are supported */
  26622. depthTextureExtension: boolean;
  26623. /** Defines if float color buffer are supported */
  26624. colorBufferFloat: boolean;
  26625. /** Gets disjoint timer query extension (null if not supported) */
  26626. timerQuery: EXT_disjoint_timer_query;
  26627. /** Defines if timestamp can be used with timer query */
  26628. canUseTimestampForTimerQuery: boolean;
  26629. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26630. multiview: any;
  26631. /** Function used to let the system compiles shaders in background */
  26632. parallelShaderCompile: {
  26633. COMPLETION_STATUS_KHR: number;
  26634. };
  26635. }
  26636. /** Interface defining initialization parameters for Engine class */
  26637. export interface EngineOptions extends WebGLContextAttributes {
  26638. /**
  26639. * Defines if the engine should no exceed a specified device ratio
  26640. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26641. */
  26642. limitDeviceRatio?: number;
  26643. /**
  26644. * Defines if webvr should be enabled automatically
  26645. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26646. */
  26647. autoEnableWebVR?: boolean;
  26648. /**
  26649. * Defines if webgl2 should be turned off even if supported
  26650. * @see http://doc.babylonjs.com/features/webgl2
  26651. */
  26652. disableWebGL2Support?: boolean;
  26653. /**
  26654. * Defines if webaudio should be initialized as well
  26655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26656. */
  26657. audioEngine?: boolean;
  26658. /**
  26659. * Defines if animations should run using a deterministic lock step
  26660. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26661. */
  26662. deterministicLockstep?: boolean;
  26663. /** Defines the maximum steps to use with deterministic lock step mode */
  26664. lockstepMaxSteps?: number;
  26665. /**
  26666. * Defines that engine should ignore context lost events
  26667. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26668. */
  26669. doNotHandleContextLost?: boolean;
  26670. /**
  26671. * Defines that engine should ignore modifying touch action attribute and style
  26672. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26673. */
  26674. doNotHandleTouchAction?: boolean;
  26675. /**
  26676. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26677. */
  26678. useHighPrecisionFloats?: boolean;
  26679. }
  26680. /**
  26681. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26682. */
  26683. export class Engine {
  26684. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26685. static ExceptionList: ({
  26686. key: string;
  26687. capture: string;
  26688. captureConstraint: number;
  26689. targets: string[];
  26690. } | {
  26691. key: string;
  26692. capture: null;
  26693. captureConstraint: null;
  26694. targets: string[];
  26695. })[];
  26696. /** Gets the list of created engines */
  26697. static readonly Instances: Engine[];
  26698. /**
  26699. * Gets the latest created engine
  26700. */
  26701. static readonly LastCreatedEngine: Nullable<Engine>;
  26702. /**
  26703. * Gets the latest created scene
  26704. */
  26705. static readonly LastCreatedScene: Nullable<Scene>;
  26706. /**
  26707. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26708. * @param flag defines which part of the materials must be marked as dirty
  26709. * @param predicate defines a predicate used to filter which materials should be affected
  26710. */
  26711. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26712. /**
  26713. * Hidden
  26714. */ private static _TextureLoaders: IInternalTextureLoader[];
  26715. /** Defines that alpha blending is disabled */
  26716. static readonly ALPHA_DISABLE: number;
  26717. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26718. static readonly ALPHA_ADD: number;
  26719. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26720. static readonly ALPHA_COMBINE: number;
  26721. /** Defines that alpha blending to DEST - SRC * DEST */
  26722. static readonly ALPHA_SUBTRACT: number;
  26723. /** Defines that alpha blending to SRC * DEST */
  26724. static readonly ALPHA_MULTIPLY: number;
  26725. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26726. static readonly ALPHA_MAXIMIZED: number;
  26727. /** Defines that alpha blending to SRC + DEST */
  26728. static readonly ALPHA_ONEONE: number;
  26729. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26730. static readonly ALPHA_PREMULTIPLIED: number;
  26731. /**
  26732. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26733. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26734. */
  26735. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26736. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26737. static readonly ALPHA_INTERPOLATE: number;
  26738. /**
  26739. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26740. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26741. */
  26742. static readonly ALPHA_SCREENMODE: number;
  26743. /** Defines that the ressource is not delayed*/
  26744. static readonly DELAYLOADSTATE_NONE: number;
  26745. /** Defines that the ressource was successfully delay loaded */
  26746. static readonly DELAYLOADSTATE_LOADED: number;
  26747. /** Defines that the ressource is currently delay loading */
  26748. static readonly DELAYLOADSTATE_LOADING: number;
  26749. /** Defines that the ressource is delayed and has not started loading */
  26750. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26751. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26752. static readonly NEVER: number;
  26753. /** 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 */
  26754. static readonly ALWAYS: number;
  26755. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26756. static readonly LESS: number;
  26757. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26758. static readonly EQUAL: number;
  26759. /** 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 */
  26760. static readonly LEQUAL: number;
  26761. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26762. static readonly GREATER: number;
  26763. /** 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 */
  26764. static readonly GEQUAL: number;
  26765. /** 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 */
  26766. static readonly NOTEQUAL: number;
  26767. /** Passed to stencilOperation to specify that stencil value must be kept */
  26768. static readonly KEEP: number;
  26769. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26770. static readonly REPLACE: number;
  26771. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26772. static readonly INCR: number;
  26773. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26774. static readonly DECR: number;
  26775. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26776. static readonly INVERT: number;
  26777. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26778. static readonly INCR_WRAP: number;
  26779. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26780. static readonly DECR_WRAP: number;
  26781. /** Texture is not repeating outside of 0..1 UVs */
  26782. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26783. /** Texture is repeating outside of 0..1 UVs */
  26784. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26785. /** Texture is repeating and mirrored */
  26786. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26787. /** ALPHA */
  26788. static readonly TEXTUREFORMAT_ALPHA: number;
  26789. /** LUMINANCE */
  26790. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26791. /** LUMINANCE_ALPHA */
  26792. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26793. /** RGB */
  26794. static readonly TEXTUREFORMAT_RGB: number;
  26795. /** RGBA */
  26796. static readonly TEXTUREFORMAT_RGBA: number;
  26797. /** RED */
  26798. static readonly TEXTUREFORMAT_RED: number;
  26799. /** RED (2nd reference) */
  26800. static readonly TEXTUREFORMAT_R: number;
  26801. /** RG */
  26802. static readonly TEXTUREFORMAT_RG: number;
  26803. /** RED_INTEGER */
  26804. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26805. /** RED_INTEGER (2nd reference) */
  26806. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26807. /** RG_INTEGER */
  26808. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26809. /** RGB_INTEGER */
  26810. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26811. /** RGBA_INTEGER */
  26812. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26813. /** UNSIGNED_BYTE */
  26814. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26815. /** UNSIGNED_BYTE (2nd reference) */
  26816. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26817. /** FLOAT */
  26818. static readonly TEXTURETYPE_FLOAT: number;
  26819. /** HALF_FLOAT */
  26820. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26821. /** BYTE */
  26822. static readonly TEXTURETYPE_BYTE: number;
  26823. /** SHORT */
  26824. static readonly TEXTURETYPE_SHORT: number;
  26825. /** UNSIGNED_SHORT */
  26826. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26827. /** INT */
  26828. static readonly TEXTURETYPE_INT: number;
  26829. /** UNSIGNED_INT */
  26830. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26831. /** UNSIGNED_SHORT_4_4_4_4 */
  26832. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26833. /** UNSIGNED_SHORT_5_5_5_1 */
  26834. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26835. /** UNSIGNED_SHORT_5_6_5 */
  26836. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26837. /** UNSIGNED_INT_2_10_10_10_REV */
  26838. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26839. /** UNSIGNED_INT_24_8 */
  26840. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26841. /** UNSIGNED_INT_10F_11F_11F_REV */
  26842. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26843. /** UNSIGNED_INT_5_9_9_9_REV */
  26844. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26845. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26846. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26847. /** nearest is mag = nearest and min = nearest and mip = linear */
  26848. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26849. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26850. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26851. /** Trilinear is mag = linear and min = linear and mip = linear */
  26852. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26853. /** nearest is mag = nearest and min = nearest and mip = linear */
  26854. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26855. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26856. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26857. /** Trilinear is mag = linear and min = linear and mip = linear */
  26858. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26859. /** mag = nearest and min = nearest and mip = nearest */
  26860. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26861. /** mag = nearest and min = linear and mip = nearest */
  26862. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26863. /** mag = nearest and min = linear and mip = linear */
  26864. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26865. /** mag = nearest and min = linear and mip = none */
  26866. static readonly TEXTURE_NEAREST_LINEAR: number;
  26867. /** mag = nearest and min = nearest and mip = none */
  26868. static readonly TEXTURE_NEAREST_NEAREST: number;
  26869. /** mag = linear and min = nearest and mip = nearest */
  26870. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26871. /** mag = linear and min = nearest and mip = linear */
  26872. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26873. /** mag = linear and min = linear and mip = none */
  26874. static readonly TEXTURE_LINEAR_LINEAR: number;
  26875. /** mag = linear and min = nearest and mip = none */
  26876. static readonly TEXTURE_LINEAR_NEAREST: number;
  26877. /** Explicit coordinates mode */
  26878. static readonly TEXTURE_EXPLICIT_MODE: number;
  26879. /** Spherical coordinates mode */
  26880. static readonly TEXTURE_SPHERICAL_MODE: number;
  26881. /** Planar coordinates mode */
  26882. static readonly TEXTURE_PLANAR_MODE: number;
  26883. /** Cubic coordinates mode */
  26884. static readonly TEXTURE_CUBIC_MODE: number;
  26885. /** Projection coordinates mode */
  26886. static readonly TEXTURE_PROJECTION_MODE: number;
  26887. /** Skybox coordinates mode */
  26888. static readonly TEXTURE_SKYBOX_MODE: number;
  26889. /** Inverse Cubic coordinates mode */
  26890. static readonly TEXTURE_INVCUBIC_MODE: number;
  26891. /** Equirectangular coordinates mode */
  26892. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26893. /** Equirectangular Fixed coordinates mode */
  26894. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26895. /** Equirectangular Fixed Mirrored coordinates mode */
  26896. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26897. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26898. static readonly SCALEMODE_FLOOR: number;
  26899. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26900. static readonly SCALEMODE_NEAREST: number;
  26901. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26902. static readonly SCALEMODE_CEILING: number;
  26903. /**
  26904. * Returns the current npm package of the sdk
  26905. */
  26906. static readonly NpmPackage: string;
  26907. /**
  26908. * Returns the current version of the framework
  26909. */
  26910. static readonly Version: string;
  26911. /**
  26912. * Returns a string describing the current engine
  26913. */
  26914. readonly description: string;
  26915. /**
  26916. * Gets or sets the epsilon value used by collision engine
  26917. */
  26918. static CollisionsEpsilon: number;
  26919. /**
  26920. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26921. */
  26922. static ShadersRepository: string;
  26923. /**
  26924. * Method called to create the default loading screen.
  26925. * This can be overriden in your own app.
  26926. * @param canvas The rendering canvas element
  26927. * @returns The loading screen
  26928. */
  26929. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26930. /**
  26931. * Method called to create the default rescale post process on each engine.
  26932. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26933. /**
  26934. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26935. */
  26936. forcePOTTextures: boolean;
  26937. /**
  26938. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26939. */
  26940. isFullscreen: boolean;
  26941. /**
  26942. * Gets a boolean indicating if the pointer is currently locked
  26943. */
  26944. isPointerLock: boolean;
  26945. /**
  26946. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26947. */
  26948. cullBackFaces: boolean;
  26949. /**
  26950. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26951. */
  26952. renderEvenInBackground: boolean;
  26953. /**
  26954. * Gets or sets a boolean indicating that cache can be kept between frames
  26955. */
  26956. preventCacheWipeBetweenFrames: boolean;
  26957. /**
  26958. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26959. **/
  26960. enableOfflineSupport: boolean;
  26961. /**
  26962. * 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)
  26963. **/
  26964. disableManifestCheck: boolean;
  26965. /**
  26966. * Gets the list of created scenes
  26967. */
  26968. scenes: Scene[];
  26969. /**
  26970. * Event raised when a new scene is created
  26971. */
  26972. onNewSceneAddedObservable: Observable<Scene>;
  26973. /**
  26974. * Gets the list of created postprocesses
  26975. */
  26976. postProcesses: PostProcess[];
  26977. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26978. validateShaderPrograms: boolean;
  26979. /**
  26980. * Observable event triggered each time the rendering canvas is resized
  26981. */
  26982. onResizeObservable: Observable<Engine>;
  26983. /**
  26984. * Observable event triggered each time the canvas loses focus
  26985. */
  26986. onCanvasBlurObservable: Observable<Engine>;
  26987. /**
  26988. * Observable event triggered each time the canvas gains focus
  26989. */
  26990. onCanvasFocusObservable: Observable<Engine>;
  26991. /**
  26992. * Observable event triggered each time the canvas receives pointerout event
  26993. */
  26994. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26995. /**
  26996. * Observable event triggered before each texture is initialized
  26997. */
  26998. onBeforeTextureInitObservable: Observable<Texture>;
  26999. /**
  27000. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27001. */
  27002. disableUniformBuffers: boolean;
  27003. /** @hidden */ uniformBuffers: UniformBuffer[];
  27004. /**
  27005. * Gets a boolean indicating that the engine supports uniform buffers
  27006. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27007. */
  27008. readonly supportsUniformBuffers: boolean;
  27009. /**
  27010. * Observable raised when the engine begins a new frame
  27011. */
  27012. onBeginFrameObservable: Observable<Engine>;
  27013. /**
  27014. * If set, will be used to request the next animation frame for the render loop
  27015. */
  27016. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27017. /**
  27018. * Observable raised when the engine ends the current frame
  27019. */
  27020. onEndFrameObservable: Observable<Engine>;
  27021. /**
  27022. * Observable raised when the engine is about to compile a shader
  27023. */
  27024. onBeforeShaderCompilationObservable: Observable<Engine>;
  27025. /**
  27026. * Observable raised when the engine has jsut compiled a shader
  27027. */
  27028. onAfterShaderCompilationObservable: Observable<Engine>;
  27029. /** @hidden */ gl: WebGLRenderingContext;
  27030. private _renderingCanvas;
  27031. private _windowIsBackground;
  27032. private _webGLVersion;
  27033. protected _highPrecisionShadersAllowed: boolean;
  27034. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  27035. /**
  27036. * Gets a boolean indicating that only power of 2 textures are supported
  27037. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27038. */
  27039. readonly needPOTTextures: boolean;
  27040. /** @hidden */ badOS: boolean;
  27041. /** @hidden */ badDesktopOS: boolean;
  27042. /**
  27043. * Gets the audio engine
  27044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27045. * @ignorenaming
  27046. */
  27047. static audioEngine: IAudioEngine;
  27048. /**
  27049. * Default AudioEngine factory responsible of creating the Audio Engine.
  27050. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27051. */
  27052. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27053. /**
  27054. * Default offline support factory responsible of creating a tool used to store data locally.
  27055. * By default, this will create a Database object if the workload has been embedded.
  27056. */
  27057. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27058. private _onFocus;
  27059. private _onBlur;
  27060. private _onCanvasPointerOut;
  27061. private _onCanvasBlur;
  27062. private _onCanvasFocus;
  27063. private _onFullscreenChange;
  27064. private _onPointerLockChange;
  27065. private _hardwareScalingLevel;
  27066. /** @hidden */ caps: EngineCapabilities;
  27067. private _pointerLockRequested;
  27068. private _isStencilEnable;
  27069. private _colorWrite;
  27070. private _loadingScreen;
  27071. /** @hidden */ drawCalls: PerfCounter;
  27072. private _glVersion;
  27073. private _glRenderer;
  27074. private _glVendor;
  27075. private _videoTextureSupported;
  27076. private _renderingQueueLaunched;
  27077. private _activeRenderLoops;
  27078. private _deterministicLockstep;
  27079. private _lockstepMaxSteps;
  27080. /**
  27081. * Observable signaled when a context lost event is raised
  27082. */
  27083. onContextLostObservable: Observable<Engine>;
  27084. /**
  27085. * Observable signaled when a context restored event is raised
  27086. */
  27087. onContextRestoredObservable: Observable<Engine>;
  27088. private _onContextLost;
  27089. private _onContextRestored;
  27090. private _contextWasLost;
  27091. /** @hidden */ doNotHandleContextLost: boolean;
  27092. /**
  27093. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27094. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27095. */
  27096. doNotHandleContextLost: boolean;
  27097. private _performanceMonitor;
  27098. private _fps;
  27099. private _deltaTime;
  27100. /**
  27101. * Turn this value on if you want to pause FPS computation when in background
  27102. */
  27103. disablePerformanceMonitorInBackground: boolean;
  27104. /**
  27105. * Gets the performance monitor attached to this engine
  27106. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27107. */
  27108. readonly performanceMonitor: PerformanceMonitor;
  27109. /**
  27110. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27111. */
  27112. disableVertexArrayObjects: boolean;
  27113. /** @hidden */
  27114. protected _depthCullingState: _DepthCullingState;
  27115. /** @hidden */
  27116. protected _stencilState: _StencilState;
  27117. /** @hidden */
  27118. protected _alphaState: _AlphaState;
  27119. /** @hidden */
  27120. protected _alphaMode: number;
  27121. /** @hidden */ internalTexturesCache: InternalTexture[];
  27122. /** @hidden */
  27123. protected _activeChannel: number;
  27124. private _currentTextureChannel;
  27125. /** @hidden */
  27126. protected _boundTexturesCache: {
  27127. [key: string]: Nullable<InternalTexture>;
  27128. };
  27129. /** @hidden */
  27130. protected _currentEffect: Nullable<Effect>;
  27131. /** @hidden */
  27132. protected _currentProgram: Nullable<WebGLProgram>;
  27133. private _compiledEffects;
  27134. private _vertexAttribArraysEnabled;
  27135. /** @hidden */
  27136. protected _cachedViewport: Nullable<Viewport>;
  27137. private _cachedVertexArrayObject;
  27138. /** @hidden */
  27139. protected _cachedVertexBuffers: any;
  27140. /** @hidden */
  27141. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27142. /** @hidden */
  27143. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27144. /** @hidden */ currentRenderTarget: Nullable<InternalTexture>;
  27145. private _uintIndicesCurrentlySet;
  27146. private _currentBoundBuffer;
  27147. /** @hidden */
  27148. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27149. private _currentBufferPointers;
  27150. private _currentInstanceLocations;
  27151. private _currentInstanceBuffers;
  27152. private _textureUnits;
  27153. /** @hidden */ workingCanvas: Nullable<HTMLCanvasElement>;
  27154. /** @hidden */ workingContext: Nullable<CanvasRenderingContext2D>;
  27155. private _rescalePostProcess;
  27156. private _dummyFramebuffer;
  27157. private _externalData;
  27158. /** @hidden */ bindedRenderFunction: any;
  27159. private _vaoRecordInProgress;
  27160. private _mustWipeVertexAttributes;
  27161. private _emptyTexture;
  27162. private _emptyCubeTexture;
  27163. private _emptyTexture3D;
  27164. /** @hidden */ frameHandler: number;
  27165. private _nextFreeTextureSlots;
  27166. private _maxSimultaneousTextures;
  27167. private _activeRequests;
  27168. private _texturesSupported;
  27169. /** @hidden */ textureFormatInUse: Nullable<string>;
  27170. /**
  27171. * Gets the list of texture formats supported
  27172. */
  27173. readonly texturesSupported: Array<string>;
  27174. /**
  27175. * Gets the list of texture formats in use
  27176. */
  27177. readonly textureFormatInUse: Nullable<string>;
  27178. /**
  27179. * Gets the current viewport
  27180. */
  27181. readonly currentViewport: Nullable<Viewport>;
  27182. /**
  27183. * Gets the default empty texture
  27184. */
  27185. readonly emptyTexture: InternalTexture;
  27186. /**
  27187. * Gets the default empty 3D texture
  27188. */
  27189. readonly emptyTexture3D: InternalTexture;
  27190. /**
  27191. * Gets the default empty cube texture
  27192. */
  27193. readonly emptyCubeTexture: InternalTexture;
  27194. /**
  27195. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27196. */
  27197. readonly premultipliedAlpha: boolean;
  27198. /**
  27199. * Creates a new engine
  27200. * @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
  27201. * @param antialias defines enable antialiasing (default: false)
  27202. * @param options defines further options to be sent to the getContext() function
  27203. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27204. */
  27205. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27206. /**
  27207. * Initializes a webVR display and starts listening to display change events
  27208. * The onVRDisplayChangedObservable will be notified upon these changes
  27209. * @returns The onVRDisplayChangedObservable
  27210. */
  27211. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27212. /** @hidden */ prepareVRComponent(): void;
  27213. /** @hidden */ connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27214. /** @hidden */ submitVRFrame(): void;
  27215. /**
  27216. * Call this function to leave webVR mode
  27217. * Will do nothing if webVR is not supported or if there is no webVR device
  27218. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27219. */
  27220. disableVR(): void;
  27221. /**
  27222. * Gets a boolean indicating that the system is in VR mode and is presenting
  27223. * @returns true if VR mode is engaged
  27224. */
  27225. isVRPresenting(): boolean;
  27226. /** @hidden */ requestVRFrame(): void;
  27227. private _disableTouchAction;
  27228. private _rebuildInternalTextures;
  27229. private _rebuildEffects;
  27230. /**
  27231. * Gets a boolean indicating if all created effects are ready
  27232. * @returns true if all effects are ready
  27233. */
  27234. areAllEffectsReady(): boolean;
  27235. private _rebuildBuffers;
  27236. private _initGLContext;
  27237. /**
  27238. * Gets version of the current webGL context
  27239. */
  27240. readonly webGLVersion: number;
  27241. /**
  27242. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27243. */
  27244. readonly isStencilEnable: boolean;
  27245. /** @hidden */ prepareWorkingCanvas(): void;
  27246. /**
  27247. * Reset the texture cache to empty state
  27248. */
  27249. resetTextureCache(): void;
  27250. /**
  27251. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27252. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27253. * @returns true if engine is in deterministic lock step mode
  27254. */
  27255. isDeterministicLockStep(): boolean;
  27256. /**
  27257. * Gets the max steps when engine is running in deterministic lock step
  27258. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27259. * @returns the max steps
  27260. */
  27261. getLockstepMaxSteps(): number;
  27262. /**
  27263. * Gets an object containing information about the current webGL context
  27264. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27265. */
  27266. getGlInfo(): {
  27267. vendor: string;
  27268. renderer: string;
  27269. version: string;
  27270. };
  27271. /**
  27272. * Gets current aspect ratio
  27273. * @param camera defines the camera to use to get the aspect ratio
  27274. * @param useScreen defines if screen size must be used (or the current render target if any)
  27275. * @returns a number defining the aspect ratio
  27276. */
  27277. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27278. /**
  27279. * Gets current screen aspect ratio
  27280. * @returns a number defining the aspect ratio
  27281. */
  27282. getScreenAspectRatio(): number;
  27283. /**
  27284. * Gets the current render width
  27285. * @param useScreen defines if screen size must be used (or the current render target if any)
  27286. * @returns a number defining the current render width
  27287. */
  27288. getRenderWidth(useScreen?: boolean): number;
  27289. /**
  27290. * Gets the current render height
  27291. * @param useScreen defines if screen size must be used (or the current render target if any)
  27292. * @returns a number defining the current render height
  27293. */
  27294. getRenderHeight(useScreen?: boolean): number;
  27295. /**
  27296. * Gets the HTML canvas attached with the current webGL context
  27297. * @returns a HTML canvas
  27298. */
  27299. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27300. /**
  27301. * Gets the client rect of the HTML canvas attached with the current webGL context
  27302. * @returns a client rectanglee
  27303. */
  27304. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27305. /**
  27306. * Defines the hardware scaling level.
  27307. * By default the hardware scaling level is computed from the window device ratio.
  27308. * 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.
  27309. * @param level defines the level to use
  27310. */
  27311. setHardwareScalingLevel(level: number): void;
  27312. /**
  27313. * Gets the current hardware scaling level.
  27314. * By default the hardware scaling level is computed from the window device ratio.
  27315. * 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.
  27316. * @returns a number indicating the current hardware scaling level
  27317. */
  27318. getHardwareScalingLevel(): number;
  27319. /**
  27320. * Gets the list of loaded textures
  27321. * @returns an array containing all loaded textures
  27322. */
  27323. getLoadedTexturesCache(): InternalTexture[];
  27324. /**
  27325. * Gets the object containing all engine capabilities
  27326. * @returns the EngineCapabilities object
  27327. */
  27328. getCaps(): EngineCapabilities;
  27329. /**
  27330. * Gets the current depth function
  27331. * @returns a number defining the depth function
  27332. */
  27333. getDepthFunction(): Nullable<number>;
  27334. /**
  27335. * Sets the current depth function
  27336. * @param depthFunc defines the function to use
  27337. */
  27338. setDepthFunction(depthFunc: number): void;
  27339. /**
  27340. * Sets the current depth function to GREATER
  27341. */
  27342. setDepthFunctionToGreater(): void;
  27343. /**
  27344. * Sets the current depth function to GEQUAL
  27345. */
  27346. setDepthFunctionToGreaterOrEqual(): void;
  27347. /**
  27348. * Sets the current depth function to LESS
  27349. */
  27350. setDepthFunctionToLess(): void;
  27351. private _cachedStencilBuffer;
  27352. private _cachedStencilFunction;
  27353. private _cachedStencilMask;
  27354. private _cachedStencilOperationPass;
  27355. private _cachedStencilOperationFail;
  27356. private _cachedStencilOperationDepthFail;
  27357. private _cachedStencilReference;
  27358. /**
  27359. * Caches the the state of the stencil buffer
  27360. */
  27361. cacheStencilState(): void;
  27362. /**
  27363. * Restores the state of the stencil buffer
  27364. */
  27365. restoreStencilState(): void;
  27366. /**
  27367. * Sets the current depth function to LEQUAL
  27368. */
  27369. setDepthFunctionToLessOrEqual(): void;
  27370. /**
  27371. * Gets a boolean indicating if stencil buffer is enabled
  27372. * @returns the current stencil buffer state
  27373. */
  27374. getStencilBuffer(): boolean;
  27375. /**
  27376. * Enable or disable the stencil buffer
  27377. * @param enable defines if the stencil buffer must be enabled or disabled
  27378. */
  27379. setStencilBuffer(enable: boolean): void;
  27380. /**
  27381. * Gets the current stencil mask
  27382. * @returns a number defining the new stencil mask to use
  27383. */
  27384. getStencilMask(): number;
  27385. /**
  27386. * Sets the current stencil mask
  27387. * @param mask defines the new stencil mask to use
  27388. */
  27389. setStencilMask(mask: number): void;
  27390. /**
  27391. * Gets the current stencil function
  27392. * @returns a number defining the stencil function to use
  27393. */
  27394. getStencilFunction(): number;
  27395. /**
  27396. * Gets the current stencil reference value
  27397. * @returns a number defining the stencil reference value to use
  27398. */
  27399. getStencilFunctionReference(): number;
  27400. /**
  27401. * Gets the current stencil mask
  27402. * @returns a number defining the stencil mask to use
  27403. */
  27404. getStencilFunctionMask(): number;
  27405. /**
  27406. * Sets the current stencil function
  27407. * @param stencilFunc defines the new stencil function to use
  27408. */
  27409. setStencilFunction(stencilFunc: number): void;
  27410. /**
  27411. * Sets the current stencil reference
  27412. * @param reference defines the new stencil reference to use
  27413. */
  27414. setStencilFunctionReference(reference: number): void;
  27415. /**
  27416. * Sets the current stencil mask
  27417. * @param mask defines the new stencil mask to use
  27418. */
  27419. setStencilFunctionMask(mask: number): void;
  27420. /**
  27421. * Gets the current stencil operation when stencil fails
  27422. * @returns a number defining stencil operation to use when stencil fails
  27423. */
  27424. getStencilOperationFail(): number;
  27425. /**
  27426. * Gets the current stencil operation when depth fails
  27427. * @returns a number defining stencil operation to use when depth fails
  27428. */
  27429. getStencilOperationDepthFail(): number;
  27430. /**
  27431. * Gets the current stencil operation when stencil passes
  27432. * @returns a number defining stencil operation to use when stencil passes
  27433. */
  27434. getStencilOperationPass(): number;
  27435. /**
  27436. * Sets the stencil operation to use when stencil fails
  27437. * @param operation defines the stencil operation to use when stencil fails
  27438. */
  27439. setStencilOperationFail(operation: number): void;
  27440. /**
  27441. * Sets the stencil operation to use when depth fails
  27442. * @param operation defines the stencil operation to use when depth fails
  27443. */
  27444. setStencilOperationDepthFail(operation: number): void;
  27445. /**
  27446. * Sets the stencil operation to use when stencil passes
  27447. * @param operation defines the stencil operation to use when stencil passes
  27448. */
  27449. setStencilOperationPass(operation: number): void;
  27450. /**
  27451. * Sets a boolean indicating if the dithering state is enabled or disabled
  27452. * @param value defines the dithering state
  27453. */
  27454. setDitheringState(value: boolean): void;
  27455. /**
  27456. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27457. * @param value defines the rasterizer state
  27458. */
  27459. setRasterizerState(value: boolean): void;
  27460. /**
  27461. * stop executing a render loop function and remove it from the execution array
  27462. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27463. */
  27464. stopRenderLoop(renderFunction?: () => void): void;
  27465. /** @hidden */ renderLoop(): void;
  27466. /**
  27467. * Register and execute a render loop. The engine can have more than one render function
  27468. * @param renderFunction defines the function to continuously execute
  27469. */
  27470. runRenderLoop(renderFunction: () => void): void;
  27471. /**
  27472. * Toggle full screen mode
  27473. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27474. */
  27475. switchFullscreen(requestPointerLock: boolean): void;
  27476. /**
  27477. * Enters full screen mode
  27478. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27479. */
  27480. enterFullscreen(requestPointerLock: boolean): void;
  27481. /**
  27482. * Exits full screen mode
  27483. */
  27484. exitFullscreen(): void;
  27485. /**
  27486. * Clear the current render buffer or the current render target (if any is set up)
  27487. * @param color defines the color to use
  27488. * @param backBuffer defines if the back buffer must be cleared
  27489. * @param depth defines if the depth buffer must be cleared
  27490. * @param stencil defines if the stencil buffer must be cleared
  27491. */
  27492. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27493. /**
  27494. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27495. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27496. * @param y defines the y-coordinate of the corner of the clear rectangle
  27497. * @param width defines the width of the clear rectangle
  27498. * @param height defines the height of the clear rectangle
  27499. * @param clearColor defines the clear color
  27500. */
  27501. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27502. /**
  27503. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27504. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27505. * @param y defines the y-coordinate of the corner of the clear rectangle
  27506. * @param width defines the width of the clear rectangle
  27507. * @param height defines the height of the clear rectangle
  27508. */
  27509. enableScissor(x: number, y: number, width: number, height: number): void;
  27510. /**
  27511. * Disable previously set scissor test rectangle
  27512. */
  27513. disableScissor(): void;
  27514. private _viewportCached;
  27515. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  27516. /**
  27517. * Set the WebGL's viewport
  27518. * @param viewport defines the viewport element to be used
  27519. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27520. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27521. */
  27522. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27523. /**
  27524. * Directly set the WebGL Viewport
  27525. * @param x defines the x coordinate of the viewport (in screen space)
  27526. * @param y defines the y coordinate of the viewport (in screen space)
  27527. * @param width defines the width of the viewport (in screen space)
  27528. * @param height defines the height of the viewport (in screen space)
  27529. * @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
  27530. */
  27531. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27532. /**
  27533. * Begin a new frame
  27534. */
  27535. beginFrame(): void;
  27536. /**
  27537. * Enf the current frame
  27538. */
  27539. endFrame(): void;
  27540. /**
  27541. * Resize the view according to the canvas' size
  27542. */
  27543. resize(): void;
  27544. /**
  27545. * Force a specific size of the canvas
  27546. * @param width defines the new canvas' width
  27547. * @param height defines the new canvas' height
  27548. */
  27549. setSize(width: number, height: number): void;
  27550. /**
  27551. * Binds the frame buffer to the specified texture.
  27552. * @param texture The texture to render to or null for the default canvas
  27553. * @param faceIndex The face of the texture to render to in case of cube texture
  27554. * @param requiredWidth The width of the target to render to
  27555. * @param requiredHeight The height of the target to render to
  27556. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27557. * @param depthStencilTexture The depth stencil texture to use to render
  27558. * @param lodLevel defines le lod level to bind to the frame buffer
  27559. */
  27560. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27561. /** @hidden */ bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  27562. /**
  27563. * Unbind the current render target texture from the webGL context
  27564. * @param texture defines the render target texture to unbind
  27565. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27566. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27567. */
  27568. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27569. /**
  27570. * Force the mipmap generation for the given render target texture
  27571. * @param texture defines the render target texture to use
  27572. */
  27573. generateMipMapsForCubemap(texture: InternalTexture): void;
  27574. /**
  27575. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27576. */
  27577. flushFramebuffer(): void;
  27578. /**
  27579. * Unbind the current render target and bind the default framebuffer
  27580. */
  27581. restoreDefaultFramebuffer(): void;
  27582. /**
  27583. * Create an uniform buffer
  27584. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27585. * @param elements defines the content of the uniform buffer
  27586. * @returns the webGL uniform buffer
  27587. */
  27588. createUniformBuffer(elements: FloatArray): DataBuffer;
  27589. /**
  27590. * Create a dynamic uniform buffer
  27591. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27592. * @param elements defines the content of the uniform buffer
  27593. * @returns the webGL uniform buffer
  27594. */
  27595. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  27596. /**
  27597. * Update an existing uniform buffer
  27598. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27599. * @param uniformBuffer defines the target uniform buffer
  27600. * @param elements defines the content to update
  27601. * @param offset defines the offset in the uniform buffer where update should start
  27602. * @param count defines the size of the data to update
  27603. */
  27604. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27605. private _resetVertexBufferBinding;
  27606. /**
  27607. * Creates a vertex buffer
  27608. * @param data the data for the vertex buffer
  27609. * @returns the new WebGL static buffer
  27610. */
  27611. createVertexBuffer(data: DataArray): DataBuffer;
  27612. /**
  27613. * Creates a dynamic vertex buffer
  27614. * @param data the data for the dynamic vertex buffer
  27615. * @returns the new WebGL dynamic buffer
  27616. */
  27617. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  27618. /**
  27619. * Update a dynamic index buffer
  27620. * @param indexBuffer defines the target index buffer
  27621. * @param indices defines the data to update
  27622. * @param offset defines the offset in the target index buffer where update should start
  27623. */
  27624. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  27625. /**
  27626. * Updates a dynamic vertex buffer.
  27627. * @param vertexBuffer the vertex buffer to update
  27628. * @param data the data used to update the vertex buffer
  27629. * @param byteOffset the byte offset of the data
  27630. * @param byteLength the byte length of the data
  27631. */
  27632. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27633. private _resetIndexBufferBinding;
  27634. /**
  27635. * Creates a new index buffer
  27636. * @param indices defines the content of the index buffer
  27637. * @param updatable defines if the index buffer must be updatable
  27638. * @returns a new webGL buffer
  27639. */
  27640. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  27641. /**
  27642. * Bind a webGL buffer to the webGL context
  27643. * @param buffer defines the buffer to bind
  27644. */
  27645. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  27646. /**
  27647. * Bind an uniform buffer to the current webGL context
  27648. * @param buffer defines the buffer to bind
  27649. */
  27650. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  27651. /**
  27652. * Bind a buffer to the current webGL context at a given location
  27653. * @param buffer defines the buffer to bind
  27654. * @param location defines the index where to bind the buffer
  27655. */
  27656. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  27657. /**
  27658. * Bind a specific block at a given index in a specific shader program
  27659. * @param pipelineContext defines the pipeline context to use
  27660. * @param blockName defines the block name
  27661. * @param index defines the index where to bind the block
  27662. */
  27663. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  27664. private bindIndexBuffer;
  27665. private bindBuffer;
  27666. /**
  27667. * update the bound buffer with the given data
  27668. * @param data defines the data to update
  27669. */
  27670. updateArrayBuffer(data: Float32Array): void;
  27671. private _vertexAttribPointer;
  27672. private _bindIndexBufferWithCache;
  27673. private _bindVertexBuffersAttributes;
  27674. /**
  27675. * Records a vertex array object
  27676. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27677. * @param vertexBuffers defines the list of vertex buffers to store
  27678. * @param indexBuffer defines the index buffer to store
  27679. * @param effect defines the effect to store
  27680. * @returns the new vertex array object
  27681. */
  27682. recordVertexArrayObject(vertexBuffers: {
  27683. [key: string]: VertexBuffer;
  27684. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  27685. /**
  27686. * Bind a specific vertex array object
  27687. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27688. * @param vertexArrayObject defines the vertex array object to bind
  27689. * @param indexBuffer defines the index buffer to bind
  27690. */
  27691. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  27692. /**
  27693. * Bind webGl buffers directly to the webGL context
  27694. * @param vertexBuffer defines the vertex buffer to bind
  27695. * @param indexBuffer defines the index buffer to bind
  27696. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27697. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27698. * @param effect defines the effect associated with the vertex buffer
  27699. */
  27700. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27701. private _unbindVertexArrayObject;
  27702. /**
  27703. * Bind a list of vertex buffers to the webGL context
  27704. * @param vertexBuffers defines the list of vertex buffers to bind
  27705. * @param indexBuffer defines the index buffer to bind
  27706. * @param effect defines the effect associated with the vertex buffers
  27707. */
  27708. bindBuffers(vertexBuffers: {
  27709. [key: string]: Nullable<VertexBuffer>;
  27710. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  27711. /**
  27712. * Unbind all instance attributes
  27713. */
  27714. unbindInstanceAttributes(): void;
  27715. /**
  27716. * Release and free the memory of a vertex array object
  27717. * @param vao defines the vertex array object to delete
  27718. */
  27719. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27720. /** @hidden */ releaseBuffer(buffer: DataBuffer): boolean;
  27721. /**
  27722. * Creates a webGL buffer to use with instanciation
  27723. * @param capacity defines the size of the buffer
  27724. * @returns the webGL buffer
  27725. */
  27726. createInstancesBuffer(capacity: number): DataBuffer;
  27727. /**
  27728. * Delete a webGL buffer used with instanciation
  27729. * @param buffer defines the webGL buffer to delete
  27730. */
  27731. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27732. /**
  27733. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27734. * @param instancesBuffer defines the webGL buffer to update and bind
  27735. * @param data defines the data to store in the buffer
  27736. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27737. */
  27738. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27739. /**
  27740. * Apply all cached states (depth, culling, stencil and alpha)
  27741. */
  27742. applyStates(): void;
  27743. /**
  27744. * Send a draw order
  27745. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27746. * @param indexStart defines the starting index
  27747. * @param indexCount defines the number of index to draw
  27748. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27749. */
  27750. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27751. /**
  27752. * Draw a list of points
  27753. * @param verticesStart defines the index of first vertex to draw
  27754. * @param verticesCount defines the count of vertices to draw
  27755. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27756. */
  27757. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27758. /**
  27759. * Draw a list of unindexed primitives
  27760. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27761. * @param verticesStart defines the index of first vertex to draw
  27762. * @param verticesCount defines the count of vertices to draw
  27763. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27764. */
  27765. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27766. /**
  27767. * Draw a list of indexed primitives
  27768. * @param fillMode defines the primitive to use
  27769. * @param indexStart defines the starting index
  27770. * @param indexCount defines the number of index to draw
  27771. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27772. */
  27773. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27774. /**
  27775. * Draw a list of unindexed primitives
  27776. * @param fillMode defines the primitive to use
  27777. * @param verticesStart defines the index of first vertex to draw
  27778. * @param verticesCount defines the count of vertices to draw
  27779. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27780. */
  27781. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27782. private _drawMode;
  27783. /** @hidden */ releaseEffect(effect: Effect): void;
  27784. /** @hidden */ deletePipelineContext(pipelineContext: IPipelineContext): void;
  27785. /**
  27786. * Create a new effect (used to store vertex/fragment shaders)
  27787. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27788. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27789. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27790. * @param samplers defines an array of string used to represent textures
  27791. * @param defines defines the string containing the defines to use to compile the shaders
  27792. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27793. * @param onCompiled defines a function to call when the effect creation is successful
  27794. * @param onError defines a function to call when the effect creation has failed
  27795. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27796. * @returns the new Effect
  27797. */
  27798. 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;
  27799. private _compileShader;
  27800. private _compileRawShader;
  27801. /**
  27802. * Directly creates a webGL program
  27803. * @param pipelineContext defines the pipeline context to attach to
  27804. * @param vertexCode defines the vertex shader code to use
  27805. * @param fragmentCode defines the fragment shader code to use
  27806. * @param context defines the webGL context to use (if not set, the current one will be used)
  27807. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27808. * @returns the new webGL program
  27809. */
  27810. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27811. /**
  27812. * Creates a webGL program
  27813. * @param pipelineContext defines the pipeline context to attach to
  27814. * @param vertexCode defines the vertex shader code to use
  27815. * @param fragmentCode defines the fragment shader code to use
  27816. * @param defines defines the string containing the defines to use to compile the shaders
  27817. * @param context defines the webGL context to use (if not set, the current one will be used)
  27818. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27819. * @returns the new webGL program
  27820. */
  27821. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27822. /**
  27823. * Creates a new pipeline context
  27824. * @returns the new pipeline
  27825. */
  27826. createPipelineContext(): WebGLPipelineContext;
  27827. private _createShaderProgram;
  27828. private _finalizePipelineContext;
  27829. /** @hidden */ preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  27830. /** @hidden */ isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  27831. /** @hidden */ executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  27832. /**
  27833. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27834. * @param pipelineContext defines the pipeline context to use
  27835. * @param uniformsNames defines the list of uniform names
  27836. * @returns an array of webGL uniform locations
  27837. */
  27838. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27839. /**
  27840. * Gets the lsit of active attributes for a given webGL program
  27841. * @param pipelineContext defines the pipeline context to use
  27842. * @param attributesNames defines the list of attribute names to get
  27843. * @returns an array of indices indicating the offset of each attribute
  27844. */
  27845. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  27846. /**
  27847. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27848. * @param effect defines the effect to activate
  27849. */
  27850. enableEffect(effect: Nullable<Effect>): void;
  27851. /**
  27852. * Set the value of an uniform to an array of int32
  27853. * @param uniform defines the webGL uniform location where to store the value
  27854. * @param array defines the array of int32 to store
  27855. */
  27856. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27857. /**
  27858. * Set the value of an uniform to an array of int32 (stored as vec2)
  27859. * @param uniform defines the webGL uniform location where to store the value
  27860. * @param array defines the array of int32 to store
  27861. */
  27862. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27863. /**
  27864. * Set the value of an uniform to an array of int32 (stored as vec3)
  27865. * @param uniform defines the webGL uniform location where to store the value
  27866. * @param array defines the array of int32 to store
  27867. */
  27868. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27869. /**
  27870. * Set the value of an uniform to an array of int32 (stored as vec4)
  27871. * @param uniform defines the webGL uniform location where to store the value
  27872. * @param array defines the array of int32 to store
  27873. */
  27874. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27875. /**
  27876. * Set the value of an uniform to an array of float32
  27877. * @param uniform defines the webGL uniform location where to store the value
  27878. * @param array defines the array of float32 to store
  27879. */
  27880. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27881. /**
  27882. * Set the value of an uniform to an array of float32 (stored as vec2)
  27883. * @param uniform defines the webGL uniform location where to store the value
  27884. * @param array defines the array of float32 to store
  27885. */
  27886. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27887. /**
  27888. * Set the value of an uniform to an array of float32 (stored as vec3)
  27889. * @param uniform defines the webGL uniform location where to store the value
  27890. * @param array defines the array of float32 to store
  27891. */
  27892. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27893. /**
  27894. * Set the value of an uniform to an array of float32 (stored as vec4)
  27895. * @param uniform defines the webGL uniform location where to store the value
  27896. * @param array defines the array of float32 to store
  27897. */
  27898. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27899. /**
  27900. * Set the value of an uniform to an array of number
  27901. * @param uniform defines the webGL uniform location where to store the value
  27902. * @param array defines the array of number to store
  27903. */
  27904. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27905. /**
  27906. * Set the value of an uniform to an array of number (stored as vec2)
  27907. * @param uniform defines the webGL uniform location where to store the value
  27908. * @param array defines the array of number to store
  27909. */
  27910. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27911. /**
  27912. * Set the value of an uniform to an array of number (stored as vec3)
  27913. * @param uniform defines the webGL uniform location where to store the value
  27914. * @param array defines the array of number to store
  27915. */
  27916. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27917. /**
  27918. * Set the value of an uniform to an array of number (stored as vec4)
  27919. * @param uniform defines the webGL uniform location where to store the value
  27920. * @param array defines the array of number to store
  27921. */
  27922. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27923. /**
  27924. * Set the value of an uniform to an array of float32 (stored as matrices)
  27925. * @param uniform defines the webGL uniform location where to store the value
  27926. * @param matrices defines the array of float32 to store
  27927. */
  27928. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27929. /**
  27930. * Set the value of an uniform to a matrix
  27931. * @param uniform defines the webGL uniform location where to store the value
  27932. * @param matrix defines the matrix to store
  27933. */
  27934. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27935. /**
  27936. * Set the value of an uniform to a matrix (3x3)
  27937. * @param uniform defines the webGL uniform location where to store the value
  27938. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27939. */
  27940. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27941. /**
  27942. * Set the value of an uniform to a matrix (2x2)
  27943. * @param uniform defines the webGL uniform location where to store the value
  27944. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27945. */
  27946. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27947. /**
  27948. * Set the value of an uniform to a number (int)
  27949. * @param uniform defines the webGL uniform location where to store the value
  27950. * @param value defines the int number to store
  27951. */
  27952. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27953. /**
  27954. * Set the value of an uniform to a number (float)
  27955. * @param uniform defines the webGL uniform location where to store the value
  27956. * @param value defines the float number to store
  27957. */
  27958. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27959. /**
  27960. * Set the value of an uniform to a vec2
  27961. * @param uniform defines the webGL uniform location where to store the value
  27962. * @param x defines the 1st component of the value
  27963. * @param y defines the 2nd component of the value
  27964. */
  27965. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27966. /**
  27967. * Set the value of an uniform to a vec3
  27968. * @param uniform defines the webGL uniform location where to store the value
  27969. * @param x defines the 1st component of the value
  27970. * @param y defines the 2nd component of the value
  27971. * @param z defines the 3rd component of the value
  27972. */
  27973. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27974. /**
  27975. * Set the value of an uniform to a boolean
  27976. * @param uniform defines the webGL uniform location where to store the value
  27977. * @param bool defines the boolean to store
  27978. */
  27979. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27980. /**
  27981. * Set the value of an uniform to a vec4
  27982. * @param uniform defines the webGL uniform location where to store the value
  27983. * @param x defines the 1st component of the value
  27984. * @param y defines the 2nd component of the value
  27985. * @param z defines the 3rd component of the value
  27986. * @param w defines the 4th component of the value
  27987. */
  27988. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27989. /**
  27990. * Set the value of an uniform to a Color3
  27991. * @param uniform defines the webGL uniform location where to store the value
  27992. * @param color3 defines the color to store
  27993. */
  27994. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27995. /**
  27996. * Set the value of an uniform to a Color3 and an alpha value
  27997. * @param uniform defines the webGL uniform location where to store the value
  27998. * @param color3 defines the color to store
  27999. * @param alpha defines the alpha component to store
  28000. */
  28001. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28002. /**
  28003. * Sets a Color4 on a uniform variable
  28004. * @param uniform defines the uniform location
  28005. * @param color4 defines the value to be set
  28006. */
  28007. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28008. /**
  28009. * Set various states to the webGL context
  28010. * @param culling defines backface culling state
  28011. * @param zOffset defines the value to apply to zOffset (0 by default)
  28012. * @param force defines if states must be applied even if cache is up to date
  28013. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28014. */
  28015. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28016. /**
  28017. * Set the z offset to apply to current rendering
  28018. * @param value defines the offset to apply
  28019. */
  28020. setZOffset(value: number): void;
  28021. /**
  28022. * Gets the current value of the zOffset
  28023. * @returns the current zOffset state
  28024. */
  28025. getZOffset(): number;
  28026. /**
  28027. * Enable or disable depth buffering
  28028. * @param enable defines the state to set
  28029. */
  28030. setDepthBuffer(enable: boolean): void;
  28031. /**
  28032. * Gets a boolean indicating if depth writing is enabled
  28033. * @returns the current depth writing state
  28034. */
  28035. getDepthWrite(): boolean;
  28036. /**
  28037. * Enable or disable depth writing
  28038. * @param enable defines the state to set
  28039. */
  28040. setDepthWrite(enable: boolean): void;
  28041. /**
  28042. * Enable or disable color writing
  28043. * @param enable defines the state to set
  28044. */
  28045. setColorWrite(enable: boolean): void;
  28046. /**
  28047. * Gets a boolean indicating if color writing is enabled
  28048. * @returns the current color writing state
  28049. */
  28050. getColorWrite(): boolean;
  28051. /**
  28052. * Sets alpha constants used by some alpha blending modes
  28053. * @param r defines the red component
  28054. * @param g defines the green component
  28055. * @param b defines the blue component
  28056. * @param a defines the alpha component
  28057. */
  28058. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28059. /**
  28060. * Sets the current alpha mode
  28061. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28062. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28063. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28064. */
  28065. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28066. /**
  28067. * Gets the current alpha mode
  28068. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28069. * @returns the current alpha mode
  28070. */
  28071. getAlphaMode(): number;
  28072. /**
  28073. * Clears the list of texture accessible through engine.
  28074. * This can help preventing texture load conflict due to name collision.
  28075. */
  28076. clearInternalTexturesCache(): void;
  28077. /**
  28078. * Force the entire cache to be cleared
  28079. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28080. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28081. */
  28082. wipeCaches(bruteForce?: boolean): void;
  28083. /**
  28084. * Set the compressed texture format to use, based on the formats you have, and the formats
  28085. * supported by the hardware / browser.
  28086. *
  28087. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28088. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28089. * to API arguments needed to compressed textures. This puts the burden on the container
  28090. * generator to house the arcane code for determining these for current & future formats.
  28091. *
  28092. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28093. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28094. *
  28095. * Note: The result of this call is not taken into account when a texture is base64.
  28096. *
  28097. * @param formatsAvailable defines the list of those format families you have created
  28098. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28099. *
  28100. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28101. * @returns The extension selected.
  28102. */
  28103. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28104. /** @hidden */ getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28105. min: number;
  28106. mag: number;
  28107. };
  28108. /** @hidden */ createTexture(): WebGLTexture;
  28109. /**
  28110. * Usually called from Texture.ts.
  28111. * Passed information to create a WebGLTexture
  28112. * @param urlArg defines a value which contains one of the following:
  28113. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28114. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28115. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28116. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28117. * @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)
  28118. * @param scene needed for loading to the correct scene
  28119. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28120. * @param onLoad optional callback to be called upon successful completion
  28121. * @param onError optional callback to be called upon failure
  28122. * @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
  28123. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28124. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28125. * @param forcedExtension defines the extension to use to pick the right loader
  28126. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28127. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28128. */
  28129. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28130. private _rescaleTexture;
  28131. private _unpackFlipYCached;
  28132. /**
  28133. * In case you are sharing the context with other applications, it might
  28134. * be interested to not cache the unpack flip y state to ensure a consistent
  28135. * value would be set.
  28136. */
  28137. enableUnpackFlipYCached: boolean;
  28138. /** @hidden */ unpackFlipY(value: boolean): void;
  28139. /** @hidden */ getUnpackAlignement(): number;
  28140. /**
  28141. * Creates a dynamic texture
  28142. * @param width defines the width of the texture
  28143. * @param height defines the height of the texture
  28144. * @param generateMipMaps defines if the engine should generate the mip levels
  28145. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28146. * @returns the dynamic texture inside an InternalTexture
  28147. */
  28148. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28149. /**
  28150. * Update the sampling mode of a given texture
  28151. * @param samplingMode defines the required sampling mode
  28152. * @param texture defines the texture to update
  28153. */
  28154. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28155. /**
  28156. * Update the content of a dynamic texture
  28157. * @param texture defines the texture to update
  28158. * @param canvas defines the canvas containing the source
  28159. * @param invertY defines if data must be stored with Y axis inverted
  28160. * @param premulAlpha defines if alpha is stored as premultiplied
  28161. * @param format defines the format of the data
  28162. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28163. */
  28164. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28165. /**
  28166. * Update a video texture
  28167. * @param texture defines the texture to update
  28168. * @param video defines the video element to use
  28169. * @param invertY defines if data must be stored with Y axis inverted
  28170. */
  28171. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28172. /**
  28173. * Updates a depth texture Comparison Mode and Function.
  28174. * If the comparison Function is equal to 0, the mode will be set to none.
  28175. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28176. * @param texture The texture to set the comparison function for
  28177. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28178. */
  28179. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28180. /** @hidden */ setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28181. width: number;
  28182. height: number;
  28183. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28184. /**
  28185. * Creates a depth stencil texture.
  28186. * This is only available in WebGL 2 or with the depth texture extension available.
  28187. * @param size The size of face edge in the texture.
  28188. * @param options The options defining the texture.
  28189. * @returns The texture
  28190. */
  28191. createDepthStencilTexture(size: number | {
  28192. width: number;
  28193. height: number;
  28194. }, options: DepthTextureCreationOptions): InternalTexture;
  28195. /**
  28196. * Creates a depth stencil texture.
  28197. * This is only available in WebGL 2 or with the depth texture extension available.
  28198. * @param size The size of face edge in the texture.
  28199. * @param options The options defining the texture.
  28200. * @returns The texture
  28201. */
  28202. private _createDepthStencilTexture;
  28203. /**
  28204. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28205. * @param renderTarget The render target to set the frame buffer for
  28206. */
  28207. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28208. /**
  28209. * Creates a new render target texture
  28210. * @param size defines the size of the texture
  28211. * @param options defines the options used to create the texture
  28212. * @returns a new render target texture stored in an InternalTexture
  28213. */
  28214. createRenderTargetTexture(size: number | {
  28215. width: number;
  28216. height: number;
  28217. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28218. /** @hidden */ setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28219. /**
  28220. * Updates the sample count of a render target texture
  28221. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28222. * @param texture defines the texture to update
  28223. * @param samples defines the sample count to set
  28224. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28225. */
  28226. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28227. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28228. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28229. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28230. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28231. /**
  28232. * @hidden
  28233. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  28234. private _prepareWebGLTextureContinuation;
  28235. private _prepareWebGLTexture;
  28236. /** @hidden */ convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28237. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  28238. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  28239. private setProgram;
  28240. private _boundUniforms;
  28241. /**
  28242. * Binds an effect to the webGL context
  28243. * @param effect defines the effect to bind
  28244. */
  28245. bindSamplers(effect: Effect): void;
  28246. private _activateCurrentTexture;
  28247. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28248. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28249. /**
  28250. * Sets a texture to the webGL context from a postprocess
  28251. * @param channel defines the channel to use
  28252. * @param postProcess defines the source postprocess
  28253. */
  28254. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28255. /**
  28256. * Binds the output of the passed in post process to the texture channel specified
  28257. * @param channel The channel the texture should be bound to
  28258. * @param postProcess The post process which's output should be bound
  28259. */
  28260. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28261. /**
  28262. * Unbind all textures from the webGL context
  28263. */
  28264. unbindAllTextures(): void;
  28265. /**
  28266. * Sets a texture to the according uniform.
  28267. * @param channel The texture channel
  28268. * @param uniform The uniform to set
  28269. * @param texture The texture to apply
  28270. */
  28271. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28272. /**
  28273. * Sets a depth stencil texture from a render target to the according uniform.
  28274. * @param channel The texture channel
  28275. * @param uniform The uniform to set
  28276. * @param texture The render target texture containing the depth stencil texture to apply
  28277. */
  28278. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28279. private _bindSamplerUniformToChannel;
  28280. private _getTextureWrapMode;
  28281. private _setTexture;
  28282. /**
  28283. * Sets an array of texture to the webGL context
  28284. * @param channel defines the channel where the texture array must be set
  28285. * @param uniform defines the associated uniform location
  28286. * @param textures defines the array of textures to bind
  28287. */
  28288. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28289. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28290. private _setTextureParameterFloat;
  28291. private _setTextureParameterInteger;
  28292. /**
  28293. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28294. * @param x defines the x coordinate of the rectangle where pixels must be read
  28295. * @param y defines the y coordinate of the rectangle where pixels must be read
  28296. * @param width defines the width of the rectangle where pixels must be read
  28297. * @param height defines the height of the rectangle where pixels must be read
  28298. * @returns a Uint8Array containing RGBA colors
  28299. */
  28300. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28301. /**
  28302. * Add an externaly attached data from its key.
  28303. * This method call will fail and return false, if such key already exists.
  28304. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28305. * @param key the unique key that identifies the data
  28306. * @param data the data object to associate to the key for this Engine instance
  28307. * @return true if no such key were already present and the data was added successfully, false otherwise
  28308. */
  28309. addExternalData<T>(key: string, data: T): boolean;
  28310. /**
  28311. * Get an externaly attached data from its key
  28312. * @param key the unique key that identifies the data
  28313. * @return the associated data, if present (can be null), or undefined if not present
  28314. */
  28315. getExternalData<T>(key: string): T;
  28316. /**
  28317. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28318. * @param key the unique key that identifies the data
  28319. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28320. * @return the associated data, can be null if the factory returned null.
  28321. */
  28322. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28323. /**
  28324. * Remove an externaly attached data from the Engine instance
  28325. * @param key the unique key that identifies the data
  28326. * @return true if the data was successfully removed, false if it doesn't exist
  28327. */
  28328. removeExternalData(key: string): boolean;
  28329. /**
  28330. * Unbind all vertex attributes from the webGL context
  28331. */
  28332. unbindAllAttributes(): void;
  28333. /**
  28334. * 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
  28335. */
  28336. releaseEffects(): void;
  28337. /**
  28338. * Dispose and release all associated resources
  28339. */
  28340. dispose(): void;
  28341. /**
  28342. * Display the loading screen
  28343. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28344. */
  28345. displayLoadingUI(): void;
  28346. /**
  28347. * Hide the loading screen
  28348. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28349. */
  28350. hideLoadingUI(): void;
  28351. /**
  28352. * Gets the current loading screen object
  28353. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28354. */
  28355. /**
  28356. * Sets the current loading screen object
  28357. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28358. */
  28359. loadingScreen: ILoadingScreen;
  28360. /**
  28361. * Sets the current loading screen text
  28362. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28363. */
  28364. loadingUIText: string;
  28365. /**
  28366. * Sets the current loading screen background color
  28367. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28368. */
  28369. loadingUIBackgroundColor: string;
  28370. /**
  28371. * Attach a new callback raised when context lost event is fired
  28372. * @param callback defines the callback to call
  28373. */
  28374. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28375. /**
  28376. * Attach a new callback raised when context restored event is fired
  28377. * @param callback defines the callback to call
  28378. */
  28379. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28380. /**
  28381. * Gets the source code of the vertex shader associated with a specific webGL program
  28382. * @param program defines the program to use
  28383. * @returns a string containing the source code of the vertex shader associated with the program
  28384. */
  28385. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28386. /**
  28387. * Gets the source code of the fragment shader associated with a specific webGL program
  28388. * @param program defines the program to use
  28389. * @returns a string containing the source code of the fragment shader associated with the program
  28390. */
  28391. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28392. /**
  28393. * Get the current error code of the webGL context
  28394. * @returns the error code
  28395. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28396. */
  28397. getError(): number;
  28398. /**
  28399. * Gets the current framerate
  28400. * @returns a number representing the framerate
  28401. */
  28402. getFps(): number;
  28403. /**
  28404. * Gets the time spent between current and previous frame
  28405. * @returns a number representing the delta time in ms
  28406. */
  28407. getDeltaTime(): number;
  28408. private _measureFps;
  28409. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28410. private _canRenderToFloatFramebuffer;
  28411. private _canRenderToHalfFloatFramebuffer;
  28412. private _canRenderToFramebuffer;
  28413. /** @hidden */ getWebGLTextureType(type: number): number;
  28414. /** @hidden */ getInternalFormat(format: number): number;
  28415. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28416. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  28417. /** @hidden */ loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  28418. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28419. /**
  28420. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28421. * @returns true if the engine can be created
  28422. * @ignorenaming
  28423. */
  28424. static isSupported(): boolean;
  28425. }
  28426. }
  28427. declare module BABYLON {
  28428. /**
  28429. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28430. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28431. */
  28432. export class EffectFallbacks {
  28433. private _defines;
  28434. private _currentRank;
  28435. private _maxRank;
  28436. private _mesh;
  28437. /**
  28438. * Removes the fallback from the bound mesh.
  28439. */
  28440. unBindMesh(): void;
  28441. /**
  28442. * Adds a fallback on the specified property.
  28443. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28444. * @param define The name of the define in the shader
  28445. */
  28446. addFallback(rank: number, define: string): void;
  28447. /**
  28448. * Sets the mesh to use CPU skinning when needing to fallback.
  28449. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28450. * @param mesh The mesh to use the fallbacks.
  28451. */
  28452. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28453. /**
  28454. * Checks to see if more fallbacks are still availible.
  28455. */
  28456. readonly isMoreFallbacks: boolean;
  28457. /**
  28458. * Removes the defines that shoould be removed when falling back.
  28459. * @param currentDefines defines the current define statements for the shader.
  28460. * @param effect defines the current effect we try to compile
  28461. * @returns The resulting defines with defines of the current rank removed.
  28462. */
  28463. reduce(currentDefines: string, effect: Effect): string;
  28464. }
  28465. /**
  28466. * Options to be used when creating an effect.
  28467. */
  28468. export class EffectCreationOptions {
  28469. /**
  28470. * Atrributes that will be used in the shader.
  28471. */
  28472. attributes: string[];
  28473. /**
  28474. * Uniform varible names that will be set in the shader.
  28475. */
  28476. uniformsNames: string[];
  28477. /**
  28478. * Uniform buffer varible names that will be set in the shader.
  28479. */
  28480. uniformBuffersNames: string[];
  28481. /**
  28482. * Sampler texture variable names that will be set in the shader.
  28483. */
  28484. samplers: string[];
  28485. /**
  28486. * Define statements that will be set in the shader.
  28487. */
  28488. defines: any;
  28489. /**
  28490. * Possible fallbacks for this effect to improve performance when needed.
  28491. */
  28492. fallbacks: Nullable<EffectFallbacks>;
  28493. /**
  28494. * Callback that will be called when the shader is compiled.
  28495. */
  28496. onCompiled: Nullable<(effect: Effect) => void>;
  28497. /**
  28498. * Callback that will be called if an error occurs during shader compilation.
  28499. */
  28500. onError: Nullable<(effect: Effect, errors: string) => void>;
  28501. /**
  28502. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28503. */
  28504. indexParameters: any;
  28505. /**
  28506. * Max number of lights that can be used in the shader.
  28507. */
  28508. maxSimultaneousLights: number;
  28509. /**
  28510. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28511. */
  28512. transformFeedbackVaryings: Nullable<string[]>;
  28513. }
  28514. /**
  28515. * Effect containing vertex and fragment shader that can be executed on an object.
  28516. */
  28517. export class Effect implements IDisposable {
  28518. /**
  28519. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28520. */
  28521. static ShadersRepository: string;
  28522. /**
  28523. * Name of the effect.
  28524. */
  28525. name: any;
  28526. /**
  28527. * String container all the define statements that should be set on the shader.
  28528. */
  28529. defines: string;
  28530. /**
  28531. * Callback that will be called when the shader is compiled.
  28532. */
  28533. onCompiled: Nullable<(effect: Effect) => void>;
  28534. /**
  28535. * Callback that will be called if an error occurs during shader compilation.
  28536. */
  28537. onError: Nullable<(effect: Effect, errors: string) => void>;
  28538. /**
  28539. * Callback that will be called when effect is bound.
  28540. */
  28541. onBind: Nullable<(effect: Effect) => void>;
  28542. /**
  28543. * Unique ID of the effect.
  28544. */
  28545. uniqueId: number;
  28546. /**
  28547. * Observable that will be called when the shader is compiled.
  28548. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28549. */
  28550. onCompileObservable: Observable<Effect>;
  28551. /**
  28552. * Observable that will be called if an error occurs during shader compilation.
  28553. */
  28554. onErrorObservable: Observable<Effect>;
  28555. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  28556. /**
  28557. * Observable that will be called when effect is bound.
  28558. */
  28559. readonly onBindObservable: Observable<Effect>;
  28560. /** @hidden */ bonesComputationForcedToCPU: boolean;
  28561. private static _uniqueIdSeed;
  28562. private _engine;
  28563. private _uniformBuffersNames;
  28564. private _uniformsNames;
  28565. private _samplerList;
  28566. private _samplers;
  28567. private _isReady;
  28568. private _compilationError;
  28569. private _attributesNames;
  28570. private _attributes;
  28571. private _uniforms;
  28572. /**
  28573. * Key for the effect.
  28574. * @hidden
  28575. */ key: string;
  28576. private _indexParameters;
  28577. private _fallbacks;
  28578. private _vertexSourceCode;
  28579. private _fragmentSourceCode;
  28580. private _vertexSourceCodeOverride;
  28581. private _fragmentSourceCodeOverride;
  28582. private _transformFeedbackVaryings;
  28583. /**
  28584. * Compiled shader to webGL program.
  28585. * @hidden
  28586. */ pipelineContext: IPipelineContext;
  28587. private _valueCache;
  28588. private static _baseCache;
  28589. /**
  28590. * Instantiates an effect.
  28591. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28592. * @param baseName Name of the effect.
  28593. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28594. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28595. * @param samplers List of sampler variables that will be passed to the shader.
  28596. * @param engine Engine to be used to render the effect
  28597. * @param defines Define statements to be added to the shader.
  28598. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28599. * @param onCompiled Callback that will be called when the shader is compiled.
  28600. * @param onError Callback that will be called if an error occurs during shader compilation.
  28601. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28602. */
  28603. 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);
  28604. /**
  28605. * Unique key for this effect
  28606. */
  28607. readonly key: string;
  28608. /**
  28609. * If the effect has been compiled and prepared.
  28610. * @returns if the effect is compiled and prepared.
  28611. */
  28612. isReady(): boolean;
  28613. /**
  28614. * The engine the effect was initialized with.
  28615. * @returns the engine.
  28616. */
  28617. getEngine(): Engine;
  28618. /**
  28619. * The pipeline context for this effect
  28620. * @returns the associated pipeline context
  28621. */
  28622. getPipelineContext(): IPipelineContext;
  28623. /**
  28624. * The set of names of attribute variables for the shader.
  28625. * @returns An array of attribute names.
  28626. */
  28627. getAttributesNames(): string[];
  28628. /**
  28629. * Returns the attribute at the given index.
  28630. * @param index The index of the attribute.
  28631. * @returns The location of the attribute.
  28632. */
  28633. getAttributeLocation(index: number): number;
  28634. /**
  28635. * Returns the attribute based on the name of the variable.
  28636. * @param name of the attribute to look up.
  28637. * @returns the attribute location.
  28638. */
  28639. getAttributeLocationByName(name: string): number;
  28640. /**
  28641. * The number of attributes.
  28642. * @returns the numnber of attributes.
  28643. */
  28644. getAttributesCount(): number;
  28645. /**
  28646. * Gets the index of a uniform variable.
  28647. * @param uniformName of the uniform to look up.
  28648. * @returns the index.
  28649. */
  28650. getUniformIndex(uniformName: string): number;
  28651. /**
  28652. * Returns the attribute based on the name of the variable.
  28653. * @param uniformName of the uniform to look up.
  28654. * @returns the location of the uniform.
  28655. */
  28656. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28657. /**
  28658. * Returns an array of sampler variable names
  28659. * @returns The array of sampler variable neames.
  28660. */
  28661. getSamplers(): string[];
  28662. /**
  28663. * The error from the last compilation.
  28664. * @returns the error string.
  28665. */
  28666. getCompilationError(): string;
  28667. /**
  28668. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28669. * @param func The callback to be used.
  28670. */
  28671. executeWhenCompiled(func: (effect: Effect) => void): void;
  28672. private _checkIsReady;
  28673. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28674. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28675. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28676. private _processShaderConversion;
  28677. private _processIncludes;
  28678. private _processPrecision;
  28679. /**
  28680. * Recompiles the webGL program
  28681. * @param vertexSourceCode The source code for the vertex shader.
  28682. * @param fragmentSourceCode The source code for the fragment shader.
  28683. * @param onCompiled Callback called when completed.
  28684. * @param onError Callback called on error.
  28685. * @hidden
  28686. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28687. /**
  28688. * Prepares the effect
  28689. * @hidden
  28690. */ prepareEffect(): void;
  28691. /**
  28692. * Checks if the effect is supported. (Must be called after compilation)
  28693. */
  28694. readonly isSupported: boolean;
  28695. /**
  28696. * Binds a texture to the engine to be used as output of the shader.
  28697. * @param channel Name of the output variable.
  28698. * @param texture Texture to bind.
  28699. * @hidden
  28700. */ bindTexture(channel: string, texture: InternalTexture): void;
  28701. /**
  28702. * Sets a texture on the engine to be used in the shader.
  28703. * @param channel Name of the sampler variable.
  28704. * @param texture Texture to set.
  28705. */
  28706. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28707. /**
  28708. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28709. * @param channel Name of the sampler variable.
  28710. * @param texture Texture to set.
  28711. */
  28712. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28713. /**
  28714. * Sets an array of textures on the engine to be used in the shader.
  28715. * @param channel Name of the variable.
  28716. * @param textures Textures to set.
  28717. */
  28718. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28719. /**
  28720. * 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)
  28721. * @param channel Name of the sampler variable.
  28722. * @param postProcess Post process to get the input texture from.
  28723. */
  28724. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28725. /**
  28726. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28727. * 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)
  28728. * @param channel Name of the sampler variable.
  28729. * @param postProcess Post process to get the output texture from.
  28730. */
  28731. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28732. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28733. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28734. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28735. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28736. /**
  28737. * Binds a buffer to a uniform.
  28738. * @param buffer Buffer to bind.
  28739. * @param name Name of the uniform variable to bind to.
  28740. */
  28741. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28742. /**
  28743. * Binds block to a uniform.
  28744. * @param blockName Name of the block to bind.
  28745. * @param index Index to bind.
  28746. */
  28747. bindUniformBlock(blockName: string, index: number): void;
  28748. /**
  28749. * Sets an interger value on a uniform variable.
  28750. * @param uniformName Name of the variable.
  28751. * @param value Value to be set.
  28752. * @returns this effect.
  28753. */
  28754. setInt(uniformName: string, value: number): Effect;
  28755. /**
  28756. * Sets an int array on a uniform variable.
  28757. * @param uniformName Name of the variable.
  28758. * @param array array to be set.
  28759. * @returns this effect.
  28760. */
  28761. setIntArray(uniformName: string, array: Int32Array): Effect;
  28762. /**
  28763. * 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)
  28764. * @param uniformName Name of the variable.
  28765. * @param array array to be set.
  28766. * @returns this effect.
  28767. */
  28768. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28769. /**
  28770. * 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)
  28771. * @param uniformName Name of the variable.
  28772. * @param array array to be set.
  28773. * @returns this effect.
  28774. */
  28775. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28776. /**
  28777. * 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)
  28778. * @param uniformName Name of the variable.
  28779. * @param array array to be set.
  28780. * @returns this effect.
  28781. */
  28782. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28783. /**
  28784. * Sets an float array on a uniform variable.
  28785. * @param uniformName Name of the variable.
  28786. * @param array array to be set.
  28787. * @returns this effect.
  28788. */
  28789. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28790. /**
  28791. * 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)
  28792. * @param uniformName Name of the variable.
  28793. * @param array array to be set.
  28794. * @returns this effect.
  28795. */
  28796. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28797. /**
  28798. * 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)
  28799. * @param uniformName Name of the variable.
  28800. * @param array array to be set.
  28801. * @returns this effect.
  28802. */
  28803. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28804. /**
  28805. * 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)
  28806. * @param uniformName Name of the variable.
  28807. * @param array array to be set.
  28808. * @returns this effect.
  28809. */
  28810. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28811. /**
  28812. * Sets an array on a uniform variable.
  28813. * @param uniformName Name of the variable.
  28814. * @param array array to be set.
  28815. * @returns this effect.
  28816. */
  28817. setArray(uniformName: string, array: number[]): Effect;
  28818. /**
  28819. * 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)
  28820. * @param uniformName Name of the variable.
  28821. * @param array array to be set.
  28822. * @returns this effect.
  28823. */
  28824. setArray2(uniformName: string, array: number[]): Effect;
  28825. /**
  28826. * 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)
  28827. * @param uniformName Name of the variable.
  28828. * @param array array to be set.
  28829. * @returns this effect.
  28830. */
  28831. setArray3(uniformName: string, array: number[]): Effect;
  28832. /**
  28833. * 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)
  28834. * @param uniformName Name of the variable.
  28835. * @param array array to be set.
  28836. * @returns this effect.
  28837. */
  28838. setArray4(uniformName: string, array: number[]): Effect;
  28839. /**
  28840. * Sets matrices on a uniform variable.
  28841. * @param uniformName Name of the variable.
  28842. * @param matrices matrices to be set.
  28843. * @returns this effect.
  28844. */
  28845. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28846. /**
  28847. * Sets matrix on a uniform variable.
  28848. * @param uniformName Name of the variable.
  28849. * @param matrix matrix to be set.
  28850. * @returns this effect.
  28851. */
  28852. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28853. /**
  28854. * 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)
  28855. * @param uniformName Name of the variable.
  28856. * @param matrix matrix to be set.
  28857. * @returns this effect.
  28858. */
  28859. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28860. /**
  28861. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28862. * @param uniformName Name of the variable.
  28863. * @param matrix matrix to be set.
  28864. * @returns this effect.
  28865. */
  28866. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28867. /**
  28868. * Sets a float on a uniform variable.
  28869. * @param uniformName Name of the variable.
  28870. * @param value value to be set.
  28871. * @returns this effect.
  28872. */
  28873. setFloat(uniformName: string, value: number): Effect;
  28874. /**
  28875. * Sets a boolean on a uniform variable.
  28876. * @param uniformName Name of the variable.
  28877. * @param bool value to be set.
  28878. * @returns this effect.
  28879. */
  28880. setBool(uniformName: string, bool: boolean): Effect;
  28881. /**
  28882. * Sets a Vector2 on a uniform variable.
  28883. * @param uniformName Name of the variable.
  28884. * @param vector2 vector2 to be set.
  28885. * @returns this effect.
  28886. */
  28887. setVector2(uniformName: string, vector2: Vector2): Effect;
  28888. /**
  28889. * Sets a float2 on a uniform variable.
  28890. * @param uniformName Name of the variable.
  28891. * @param x First float in float2.
  28892. * @param y Second float in float2.
  28893. * @returns this effect.
  28894. */
  28895. setFloat2(uniformName: string, x: number, y: number): Effect;
  28896. /**
  28897. * Sets a Vector3 on a uniform variable.
  28898. * @param uniformName Name of the variable.
  28899. * @param vector3 Value to be set.
  28900. * @returns this effect.
  28901. */
  28902. setVector3(uniformName: string, vector3: Vector3): Effect;
  28903. /**
  28904. * Sets a float3 on a uniform variable.
  28905. * @param uniformName Name of the variable.
  28906. * @param x First float in float3.
  28907. * @param y Second float in float3.
  28908. * @param z Third float in float3.
  28909. * @returns this effect.
  28910. */
  28911. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28912. /**
  28913. * Sets a Vector4 on a uniform variable.
  28914. * @param uniformName Name of the variable.
  28915. * @param vector4 Value to be set.
  28916. * @returns this effect.
  28917. */
  28918. setVector4(uniformName: string, vector4: Vector4): Effect;
  28919. /**
  28920. * Sets a float4 on a uniform variable.
  28921. * @param uniformName Name of the variable.
  28922. * @param x First float in float4.
  28923. * @param y Second float in float4.
  28924. * @param z Third float in float4.
  28925. * @param w Fourth float in float4.
  28926. * @returns this effect.
  28927. */
  28928. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28929. /**
  28930. * Sets a Color3 on a uniform variable.
  28931. * @param uniformName Name of the variable.
  28932. * @param color3 Value to be set.
  28933. * @returns this effect.
  28934. */
  28935. setColor3(uniformName: string, color3: Color3): Effect;
  28936. /**
  28937. * Sets a Color4 on a uniform variable.
  28938. * @param uniformName Name of the variable.
  28939. * @param color3 Value to be set.
  28940. * @param alpha Alpha value to be set.
  28941. * @returns this effect.
  28942. */
  28943. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28944. /**
  28945. * Sets a Color4 on a uniform variable
  28946. * @param uniformName defines the name of the variable
  28947. * @param color4 defines the value to be set
  28948. * @returns this effect.
  28949. */
  28950. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28951. /** Release all associated resources */
  28952. dispose(): void;
  28953. /**
  28954. * This function will add a new shader to the shader store
  28955. * @param name the name of the shader
  28956. * @param pixelShader optional pixel shader content
  28957. * @param vertexShader optional vertex shader content
  28958. */
  28959. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28960. /**
  28961. * Store of each shader (The can be looked up using effect.key)
  28962. */
  28963. static ShadersStore: {
  28964. [key: string]: string;
  28965. };
  28966. /**
  28967. * Store of each included file for a shader (The can be looked up using effect.key)
  28968. */
  28969. static IncludesShadersStore: {
  28970. [key: string]: string;
  28971. };
  28972. /**
  28973. * Resets the cache of effects.
  28974. */
  28975. static ResetCache(): void;
  28976. }
  28977. }
  28978. declare module BABYLON {
  28979. /**
  28980. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28981. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28982. * 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;
  28983. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28984. */
  28985. export class ColorCurves {
  28986. private _dirty;
  28987. private _tempColor;
  28988. private _globalCurve;
  28989. private _highlightsCurve;
  28990. private _midtonesCurve;
  28991. private _shadowsCurve;
  28992. private _positiveCurve;
  28993. private _negativeCurve;
  28994. private _globalHue;
  28995. private _globalDensity;
  28996. private _globalSaturation;
  28997. private _globalExposure;
  28998. /**
  28999. * Gets the global Hue value.
  29000. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  29001. */
  29002. /**
  29003. * Sets the global Hue value.
  29004. * 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).
  29005. */
  29006. globalHue: number;
  29007. /**
  29008. * Gets the global Density value.
  29009. * 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.
  29010. * Values less than zero provide a filter of opposite hue.
  29011. */
  29012. /**
  29013. * Sets the global Density value.
  29014. * 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.
  29015. * Values less than zero provide a filter of opposite hue.
  29016. */
  29017. globalDensity: number;
  29018. /**
  29019. * Gets the global Saturation value.
  29020. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29021. */
  29022. /**
  29023. * Sets the global Saturation value.
  29024. * 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.
  29025. */
  29026. globalSaturation: number;
  29027. /**
  29028. * Gets the global Exposure value.
  29029. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29030. */
  29031. /**
  29032. * Sets the global Exposure value.
  29033. * 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.
  29034. */
  29035. globalExposure: number;
  29036. private _highlightsHue;
  29037. private _highlightsDensity;
  29038. private _highlightsSaturation;
  29039. private _highlightsExposure;
  29040. /**
  29041. * Gets the highlights Hue value.
  29042. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  29043. */
  29044. /**
  29045. * Sets the highlights Hue value.
  29046. * 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).
  29047. */
  29048. highlightsHue: number;
  29049. /**
  29050. * Gets the highlights Density value.
  29051. * 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.
  29052. * Values less than zero provide a filter of opposite hue.
  29053. */
  29054. /**
  29055. * Sets the highlights Density value.
  29056. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  29057. * Values less than zero provide a filter of opposite hue.
  29058. */
  29059. highlightsDensity: number;
  29060. /**
  29061. * Gets the highlights Saturation value.
  29062. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29063. */
  29064. /**
  29065. * Sets the highlights Saturation value.
  29066. * 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.
  29067. */
  29068. highlightsSaturation: number;
  29069. /**
  29070. * Gets the highlights Exposure value.
  29071. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29072. */
  29073. /**
  29074. * Sets the highlights Exposure value.
  29075. * 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.
  29076. */
  29077. highlightsExposure: number;
  29078. private _midtonesHue;
  29079. private _midtonesDensity;
  29080. private _midtonesSaturation;
  29081. private _midtonesExposure;
  29082. /**
  29083. * Gets the midtones Hue value.
  29084. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  29085. */
  29086. /**
  29087. * Sets the midtones Hue value.
  29088. * 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).
  29089. */
  29090. midtonesHue: number;
  29091. /**
  29092. * Gets the midtones Density value.
  29093. * 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.
  29094. * Values less than zero provide a filter of opposite hue.
  29095. */
  29096. /**
  29097. * Sets the midtones Density value.
  29098. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  29099. * Values less than zero provide a filter of opposite hue.
  29100. */
  29101. midtonesDensity: number;
  29102. /**
  29103. * Gets the midtones Saturation value.
  29104. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29105. */
  29106. /**
  29107. * Sets the midtones Saturation value.
  29108. * 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.
  29109. */
  29110. midtonesSaturation: number;
  29111. /**
  29112. * Gets the midtones Exposure value.
  29113. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29114. */
  29115. /**
  29116. * Sets the midtones Exposure value.
  29117. * 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.
  29118. */
  29119. midtonesExposure: number;
  29120. private _shadowsHue;
  29121. private _shadowsDensity;
  29122. private _shadowsSaturation;
  29123. private _shadowsExposure;
  29124. /**
  29125. * Gets the shadows Hue value.
  29126. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  29127. */
  29128. /**
  29129. * Sets the shadows Hue value.
  29130. * 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).
  29131. */
  29132. shadowsHue: number;
  29133. /**
  29134. * Gets the shadows Density value.
  29135. * 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.
  29136. * Values less than zero provide a filter of opposite hue.
  29137. */
  29138. /**
  29139. * Sets the shadows Density value.
  29140. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  29141. * Values less than zero provide a filter of opposite hue.
  29142. */
  29143. shadowsDensity: number;
  29144. /**
  29145. * Gets the shadows Saturation value.
  29146. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29147. */
  29148. /**
  29149. * Sets the shadows Saturation value.
  29150. * 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.
  29151. */
  29152. shadowsSaturation: number;
  29153. /**
  29154. * Gets the shadows Exposure value.
  29155. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29156. */
  29157. /**
  29158. * Sets the shadows Exposure value.
  29159. * 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.
  29160. */
  29161. shadowsExposure: number;
  29162. /**
  29163. * Returns the class name
  29164. * @returns The class name
  29165. */
  29166. getClassName(): string;
  29167. /**
  29168. * Binds the color curves to the shader.
  29169. * @param colorCurves The color curve to bind
  29170. * @param effect The effect to bind to
  29171. * @param positiveUniform The positive uniform shader parameter
  29172. * @param neutralUniform The neutral uniform shader parameter
  29173. * @param negativeUniform The negative uniform shader parameter
  29174. */
  29175. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29176. /**
  29177. * Prepare the list of uniforms associated with the ColorCurves effects.
  29178. * @param uniformsList The list of uniforms used in the effect
  29179. */
  29180. static PrepareUniforms(uniformsList: string[]): void;
  29181. /**
  29182. * Returns color grading data based on a hue, density, saturation and exposure value.
  29183. * @param filterHue The hue of the color filter.
  29184. * @param filterDensity The density of the color filter.
  29185. * @param saturation The saturation.
  29186. * @param exposure The exposure.
  29187. * @param result The result data container.
  29188. */
  29189. private getColorGradingDataToRef;
  29190. /**
  29191. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29192. * @param value The input slider value in range [-100,100].
  29193. * @returns Adjusted value.
  29194. */
  29195. private static applyColorGradingSliderNonlinear;
  29196. /**
  29197. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29198. * @param hue The hue (H) input.
  29199. * @param saturation The saturation (S) input.
  29200. * @param brightness The brightness (B) input.
  29201. * @result An RGBA color represented as Vector4.
  29202. */
  29203. private static fromHSBToRef;
  29204. /**
  29205. * Returns a value clamped between min and max
  29206. * @param value The value to clamp
  29207. * @param min The minimum of value
  29208. * @param max The maximum of value
  29209. * @returns The clamped value.
  29210. */
  29211. private static clamp;
  29212. /**
  29213. * Clones the current color curve instance.
  29214. * @return The cloned curves
  29215. */
  29216. clone(): ColorCurves;
  29217. /**
  29218. * Serializes the current color curve instance to a json representation.
  29219. * @return a JSON representation
  29220. */
  29221. serialize(): any;
  29222. /**
  29223. * Parses the color curve from a json representation.
  29224. * @param source the JSON source to parse
  29225. * @return The parsed curves
  29226. */
  29227. static Parse(source: any): ColorCurves;
  29228. }
  29229. }
  29230. declare module BABYLON {
  29231. /**
  29232. * Interface to follow in your material defines to integrate easily the
  29233. * Image proccessing functions.
  29234. * @hidden
  29235. */
  29236. export interface IImageProcessingConfigurationDefines {
  29237. IMAGEPROCESSING: boolean;
  29238. VIGNETTE: boolean;
  29239. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29240. VIGNETTEBLENDMODEOPAQUE: boolean;
  29241. TONEMAPPING: boolean;
  29242. TONEMAPPING_ACES: boolean;
  29243. CONTRAST: boolean;
  29244. EXPOSURE: boolean;
  29245. COLORCURVES: boolean;
  29246. COLORGRADING: boolean;
  29247. COLORGRADING3D: boolean;
  29248. SAMPLER3DGREENDEPTH: boolean;
  29249. SAMPLER3DBGRMAP: boolean;
  29250. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29251. }
  29252. /**
  29253. * @hidden
  29254. */
  29255. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29256. IMAGEPROCESSING: boolean;
  29257. VIGNETTE: boolean;
  29258. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29259. VIGNETTEBLENDMODEOPAQUE: boolean;
  29260. TONEMAPPING: boolean;
  29261. TONEMAPPING_ACES: boolean;
  29262. CONTRAST: boolean;
  29263. COLORCURVES: boolean;
  29264. COLORGRADING: boolean;
  29265. COLORGRADING3D: boolean;
  29266. SAMPLER3DGREENDEPTH: boolean;
  29267. SAMPLER3DBGRMAP: boolean;
  29268. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29269. EXPOSURE: boolean;
  29270. constructor();
  29271. }
  29272. /**
  29273. * This groups together the common properties used for image processing either in direct forward pass
  29274. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29275. * or not.
  29276. */
  29277. export class ImageProcessingConfiguration {
  29278. /**
  29279. * Default tone mapping applied in BabylonJS.
  29280. */
  29281. static readonly TONEMAPPING_STANDARD: number;
  29282. /**
  29283. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29284. * to other engines rendering to increase portability.
  29285. */
  29286. static readonly TONEMAPPING_ACES: number;
  29287. /**
  29288. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29289. */
  29290. colorCurves: Nullable<ColorCurves>;
  29291. private _colorCurvesEnabled;
  29292. /**
  29293. * Gets wether the color curves effect is enabled.
  29294. */
  29295. /**
  29296. * Sets wether the color curves effect is enabled.
  29297. */
  29298. colorCurvesEnabled: boolean;
  29299. private _colorGradingTexture;
  29300. /**
  29301. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29302. */
  29303. /**
  29304. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29305. */
  29306. colorGradingTexture: Nullable<BaseTexture>;
  29307. private _colorGradingEnabled;
  29308. /**
  29309. * Gets wether the color grading effect is enabled.
  29310. */
  29311. /**
  29312. * Sets wether the color grading effect is enabled.
  29313. */
  29314. colorGradingEnabled: boolean;
  29315. private _colorGradingWithGreenDepth;
  29316. /**
  29317. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29318. */
  29319. /**
  29320. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29321. */
  29322. colorGradingWithGreenDepth: boolean;
  29323. private _colorGradingBGR;
  29324. /**
  29325. * Gets wether the color grading texture contains BGR values.
  29326. */
  29327. /**
  29328. * Sets wether the color grading texture contains BGR values.
  29329. */
  29330. colorGradingBGR: boolean;
  29331. /** @hidden */ exposure: number;
  29332. /**
  29333. * Gets the Exposure used in the effect.
  29334. */
  29335. /**
  29336. * Sets the Exposure used in the effect.
  29337. */
  29338. exposure: number;
  29339. private _toneMappingEnabled;
  29340. /**
  29341. * Gets wether the tone mapping effect is enabled.
  29342. */
  29343. /**
  29344. * Sets wether the tone mapping effect is enabled.
  29345. */
  29346. toneMappingEnabled: boolean;
  29347. private _toneMappingType;
  29348. /**
  29349. * Gets the type of tone mapping effect.
  29350. */
  29351. /**
  29352. * Sets the type of tone mapping effect used in BabylonJS.
  29353. */
  29354. toneMappingType: number;
  29355. protected _contrast: number;
  29356. /**
  29357. * Gets the contrast used in the effect.
  29358. */
  29359. /**
  29360. * Sets the contrast used in the effect.
  29361. */
  29362. contrast: number;
  29363. /**
  29364. * Vignette stretch size.
  29365. */
  29366. vignetteStretch: number;
  29367. /**
  29368. * Vignette centre X Offset.
  29369. */
  29370. vignetteCentreX: number;
  29371. /**
  29372. * Vignette centre Y Offset.
  29373. */
  29374. vignetteCentreY: number;
  29375. /**
  29376. * Vignette weight or intensity of the vignette effect.
  29377. */
  29378. vignetteWeight: number;
  29379. /**
  29380. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29381. * if vignetteEnabled is set to true.
  29382. */
  29383. vignetteColor: Color4;
  29384. /**
  29385. * Camera field of view used by the Vignette effect.
  29386. */
  29387. vignetteCameraFov: number;
  29388. private _vignetteBlendMode;
  29389. /**
  29390. * Gets the vignette blend mode allowing different kind of effect.
  29391. */
  29392. /**
  29393. * Sets the vignette blend mode allowing different kind of effect.
  29394. */
  29395. vignetteBlendMode: number;
  29396. private _vignetteEnabled;
  29397. /**
  29398. * Gets wether the vignette effect is enabled.
  29399. */
  29400. /**
  29401. * Sets wether the vignette effect is enabled.
  29402. */
  29403. vignetteEnabled: boolean;
  29404. private _applyByPostProcess;
  29405. /**
  29406. * Gets wether the image processing is applied through a post process or not.
  29407. */
  29408. /**
  29409. * Sets wether the image processing is applied through a post process or not.
  29410. */
  29411. applyByPostProcess: boolean;
  29412. private _isEnabled;
  29413. /**
  29414. * Gets wether the image processing is enabled or not.
  29415. */
  29416. /**
  29417. * Sets wether the image processing is enabled or not.
  29418. */
  29419. isEnabled: boolean;
  29420. /**
  29421. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29422. */
  29423. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29424. /**
  29425. * Method called each time the image processing information changes requires to recompile the effect.
  29426. */
  29427. protected _updateParameters(): void;
  29428. /**
  29429. * Gets the current class name.
  29430. * @return "ImageProcessingConfiguration"
  29431. */
  29432. getClassName(): string;
  29433. /**
  29434. * Prepare the list of uniforms associated with the Image Processing effects.
  29435. * @param uniforms The list of uniforms used in the effect
  29436. * @param defines the list of defines currently in use
  29437. */
  29438. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29439. /**
  29440. * Prepare the list of samplers associated with the Image Processing effects.
  29441. * @param samplersList The list of uniforms used in the effect
  29442. * @param defines the list of defines currently in use
  29443. */
  29444. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29445. /**
  29446. * Prepare the list of defines associated to the shader.
  29447. * @param defines the list of defines to complete
  29448. * @param forPostProcess Define if we are currently in post process mode or not
  29449. */
  29450. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29451. /**
  29452. * Returns true if all the image processing information are ready.
  29453. * @returns True if ready, otherwise, false
  29454. */
  29455. isReady(): boolean;
  29456. /**
  29457. * Binds the image processing to the shader.
  29458. * @param effect The effect to bind to
  29459. * @param aspectRatio Define the current aspect ratio of the effect
  29460. */
  29461. bind(effect: Effect, aspectRatio?: number): void;
  29462. /**
  29463. * Clones the current image processing instance.
  29464. * @return The cloned image processing
  29465. */
  29466. clone(): ImageProcessingConfiguration;
  29467. /**
  29468. * Serializes the current image processing instance to a json representation.
  29469. * @return a JSON representation
  29470. */
  29471. serialize(): any;
  29472. /**
  29473. * Parses the image processing from a json representation.
  29474. * @param source the JSON source to parse
  29475. * @return The parsed image processing
  29476. */
  29477. static Parse(source: any): ImageProcessingConfiguration;
  29478. private static _VIGNETTEMODE_MULTIPLY;
  29479. private static _VIGNETTEMODE_OPAQUE;
  29480. /**
  29481. * Used to apply the vignette as a mix with the pixel color.
  29482. */
  29483. static readonly VIGNETTEMODE_MULTIPLY: number;
  29484. /**
  29485. * Used to apply the vignette as a replacement of the pixel color.
  29486. */
  29487. static readonly VIGNETTEMODE_OPAQUE: number;
  29488. }
  29489. }
  29490. declare module BABYLON {
  29491. /**
  29492. * This represents all the required information to add a fresnel effect on a material:
  29493. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29494. */
  29495. export class FresnelParameters {
  29496. private _isEnabled;
  29497. /**
  29498. * Define if the fresnel effect is enable or not.
  29499. */
  29500. isEnabled: boolean;
  29501. /**
  29502. * Define the color used on edges (grazing angle)
  29503. */
  29504. leftColor: Color3;
  29505. /**
  29506. * Define the color used on center
  29507. */
  29508. rightColor: Color3;
  29509. /**
  29510. * Define bias applied to computed fresnel term
  29511. */
  29512. bias: number;
  29513. /**
  29514. * Defined the power exponent applied to fresnel term
  29515. */
  29516. power: number;
  29517. /**
  29518. * Clones the current fresnel and its valuues
  29519. * @returns a clone fresnel configuration
  29520. */
  29521. clone(): FresnelParameters;
  29522. /**
  29523. * Serializes the current fresnel parameters to a JSON representation.
  29524. * @return the JSON serialization
  29525. */
  29526. serialize(): any;
  29527. /**
  29528. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29529. * @param parsedFresnelParameters Define the JSON representation
  29530. * @returns the parsed parameters
  29531. */
  29532. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29533. }
  29534. }
  29535. declare module BABYLON {
  29536. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29537. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29538. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29539. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29540. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29541. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29542. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29543. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29544. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29545. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29546. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29547. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29548. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29549. /**
  29550. * Decorator used to define property that can be serialized as reference to a camera
  29551. * @param sourceName defines the name of the property to decorate
  29552. */
  29553. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29554. /**
  29555. * Class used to help serialization objects
  29556. */
  29557. export class SerializationHelper {
  29558. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29559. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29560. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29561. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29562. /**
  29563. * Appends the serialized animations from the source animations
  29564. * @param source Source containing the animations
  29565. * @param destination Target to store the animations
  29566. */
  29567. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29568. /**
  29569. * Static function used to serialized a specific entity
  29570. * @param entity defines the entity to serialize
  29571. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29572. * @returns a JSON compatible object representing the serialization of the entity
  29573. */
  29574. static Serialize<T>(entity: T, serializationObject?: any): any;
  29575. /**
  29576. * Creates a new entity from a serialization data object
  29577. * @param creationFunction defines a function used to instanciated the new entity
  29578. * @param source defines the source serialization data
  29579. * @param scene defines the hosting scene
  29580. * @param rootUrl defines the root url for resources
  29581. * @returns a new entity
  29582. */
  29583. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29584. /**
  29585. * Clones an object
  29586. * @param creationFunction defines the function used to instanciate the new object
  29587. * @param source defines the source object
  29588. * @returns the cloned object
  29589. */
  29590. static Clone<T>(creationFunction: () => T, source: T): T;
  29591. /**
  29592. * Instanciates a new object based on a source one (some data will be shared between both object)
  29593. * @param creationFunction defines the function used to instanciate the new object
  29594. * @param source defines the source object
  29595. * @returns the new object
  29596. */
  29597. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29598. }
  29599. }
  29600. declare module BABYLON {
  29601. /**
  29602. * This is the base class of all the camera used in the application.
  29603. * @see http://doc.babylonjs.com/features/cameras
  29604. */
  29605. export class Camera extends Node {
  29606. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29607. /**
  29608. * This is the default projection mode used by the cameras.
  29609. * It helps recreating a feeling of perspective and better appreciate depth.
  29610. * This is the best way to simulate real life cameras.
  29611. */
  29612. static readonly PERSPECTIVE_CAMERA: number;
  29613. /**
  29614. * This helps creating camera with an orthographic mode.
  29615. * 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.
  29616. */
  29617. static readonly ORTHOGRAPHIC_CAMERA: number;
  29618. /**
  29619. * This is the default FOV mode for perspective cameras.
  29620. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29621. */
  29622. static readonly FOVMODE_VERTICAL_FIXED: number;
  29623. /**
  29624. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29625. */
  29626. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29627. /**
  29628. * This specifies ther is no need for a camera rig.
  29629. * Basically only one eye is rendered corresponding to the camera.
  29630. */
  29631. static readonly RIG_MODE_NONE: number;
  29632. /**
  29633. * Simulates a camera Rig with one blue eye and one red eye.
  29634. * This can be use with 3d blue and red glasses.
  29635. */
  29636. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29637. /**
  29638. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29639. */
  29640. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29641. /**
  29642. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29643. */
  29644. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29645. /**
  29646. * Defines that both eyes of the camera will be rendered over under each other.
  29647. */
  29648. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29649. /**
  29650. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29651. */
  29652. static readonly RIG_MODE_VR: number;
  29653. /**
  29654. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29655. */
  29656. static readonly RIG_MODE_WEBVR: number;
  29657. /**
  29658. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29659. */
  29660. static readonly RIG_MODE_CUSTOM: number;
  29661. /**
  29662. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29663. */
  29664. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29665. /**
  29666. * Define the input manager associated with the camera.
  29667. */
  29668. inputs: CameraInputsManager<Camera>;
  29669. /** @hidden */ position: Vector3;
  29670. /**
  29671. * Define the current local position of the camera in the scene
  29672. */
  29673. position: Vector3;
  29674. /**
  29675. * The vector the camera should consider as up.
  29676. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29677. */
  29678. upVector: Vector3;
  29679. /**
  29680. * Define the current limit on the left side for an orthographic camera
  29681. * In scene unit
  29682. */
  29683. orthoLeft: Nullable<number>;
  29684. /**
  29685. * Define the current limit on the right side for an orthographic camera
  29686. * In scene unit
  29687. */
  29688. orthoRight: Nullable<number>;
  29689. /**
  29690. * Define the current limit on the bottom side for an orthographic camera
  29691. * In scene unit
  29692. */
  29693. orthoBottom: Nullable<number>;
  29694. /**
  29695. * Define the current limit on the top side for an orthographic camera
  29696. * In scene unit
  29697. */
  29698. orthoTop: Nullable<number>;
  29699. /**
  29700. * Field Of View is set in Radians. (default is 0.8)
  29701. */
  29702. fov: number;
  29703. /**
  29704. * Define the minimum distance the camera can see from.
  29705. * This is important to note that the depth buffer are not infinite and the closer it starts
  29706. * the more your scene might encounter depth fighting issue.
  29707. */
  29708. minZ: number;
  29709. /**
  29710. * Define the maximum distance the camera can see to.
  29711. * This is important to note that the depth buffer are not infinite and the further it end
  29712. * the more your scene might encounter depth fighting issue.
  29713. */
  29714. maxZ: number;
  29715. /**
  29716. * Define the default inertia of the camera.
  29717. * This helps giving a smooth feeling to the camera movement.
  29718. */
  29719. inertia: number;
  29720. /**
  29721. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29722. */
  29723. mode: number;
  29724. /**
  29725. * Define wether the camera is intermediate.
  29726. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29727. */
  29728. isIntermediate: boolean;
  29729. /**
  29730. * Define the viewport of the camera.
  29731. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29732. */
  29733. viewport: Viewport;
  29734. /**
  29735. * Restricts the camera to viewing objects with the same layerMask.
  29736. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29737. */
  29738. layerMask: number;
  29739. /**
  29740. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29741. */
  29742. fovMode: number;
  29743. /**
  29744. * Rig mode of the camera.
  29745. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29746. * This is normally controlled byt the camera themselves as internal use.
  29747. */
  29748. cameraRigMode: number;
  29749. /**
  29750. * Defines the distance between both "eyes" in case of a RIG
  29751. */
  29752. interaxialDistance: number;
  29753. /**
  29754. * Defines if stereoscopic rendering is done side by side or over under.
  29755. */
  29756. isStereoscopicSideBySide: boolean;
  29757. /**
  29758. * 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
  29759. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29760. * else in the scene.
  29761. */
  29762. customRenderTargets: RenderTargetTexture[];
  29763. /**
  29764. * When set, the camera will render to this render target instead of the default canvas
  29765. */
  29766. outputRenderTarget: Nullable<RenderTargetTexture>;
  29767. /**
  29768. * Observable triggered when the camera view matrix has changed.
  29769. */
  29770. onViewMatrixChangedObservable: Observable<Camera>;
  29771. /**
  29772. * Observable triggered when the camera Projection matrix has changed.
  29773. */
  29774. onProjectionMatrixChangedObservable: Observable<Camera>;
  29775. /**
  29776. * Observable triggered when the inputs have been processed.
  29777. */
  29778. onAfterCheckInputsObservable: Observable<Camera>;
  29779. /**
  29780. * Observable triggered when reset has been called and applied to the camera.
  29781. */
  29782. onRestoreStateObservable: Observable<Camera>;
  29783. /** @hidden */ cameraRigParams: any;
  29784. /** @hidden */ rigCameras: Camera[];
  29785. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  29786. protected _webvrViewMatrix: Matrix;
  29787. /** @hidden */ skipRendering: boolean;
  29788. /** @hidden */ projectionMatrix: Matrix;
  29789. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  29790. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  29791. protected _globalPosition: Vector3;
  29792. /** hidden */ computedViewMatrix: Matrix;
  29793. private _doNotComputeProjectionMatrix;
  29794. private _transformMatrix;
  29795. private _frustumPlanes;
  29796. private _refreshFrustumPlanes;
  29797. private _storedFov;
  29798. private _stateStored;
  29799. /**
  29800. * Instantiates a new camera object.
  29801. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29802. * @see http://doc.babylonjs.com/features/cameras
  29803. * @param name Defines the name of the camera in the scene
  29804. * @param position Defines the position of the camera
  29805. * @param scene Defines the scene the camera belongs too
  29806. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29807. */
  29808. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29809. /**
  29810. * Store current camera state (fov, position, etc..)
  29811. * @returns the camera
  29812. */
  29813. storeState(): Camera;
  29814. /**
  29815. * Restores the camera state values if it has been stored. You must call storeState() first
  29816. */
  29817. protected _restoreStateValues(): boolean;
  29818. /**
  29819. * Restored camera state. You must call storeState() first.
  29820. * @returns true if restored and false otherwise
  29821. */
  29822. restoreState(): boolean;
  29823. /**
  29824. * Gets the class name of the camera.
  29825. * @returns the class name
  29826. */
  29827. getClassName(): string;
  29828. /** @hidden */ protected readonly _isCamera: boolean;
  29829. /**
  29830. * Gets a string representation of the camera useful for debug purpose.
  29831. * @param fullDetails Defines that a more verboe level of logging is required
  29832. * @returns the string representation
  29833. */
  29834. toString(fullDetails?: boolean): string;
  29835. /**
  29836. * Gets the current world space position of the camera.
  29837. */
  29838. readonly globalPosition: Vector3;
  29839. /**
  29840. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29841. * @returns the active meshe list
  29842. */
  29843. getActiveMeshes(): SmartArray<AbstractMesh>;
  29844. /**
  29845. * Check wether a mesh is part of the current active mesh list of the camera
  29846. * @param mesh Defines the mesh to check
  29847. * @returns true if active, false otherwise
  29848. */
  29849. isActiveMesh(mesh: Mesh): boolean;
  29850. /**
  29851. * Is this camera ready to be used/rendered
  29852. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29853. * @return true if the camera is ready
  29854. */
  29855. isReady(completeCheck?: boolean): boolean;
  29856. /** @hidden */ initCache(): void;
  29857. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29858. /** @hidden */ isSynchronized(): boolean;
  29859. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29860. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29861. /**
  29862. * Attach the input controls to a specific dom element to get the input from.
  29863. * @param element Defines the element the controls should be listened from
  29864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29865. */
  29866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29867. /**
  29868. * Detach the current controls from the specified dom element.
  29869. * @param element Defines the element to stop listening the inputs from
  29870. */
  29871. detachControl(element: HTMLElement): void;
  29872. /**
  29873. * Update the camera state according to the different inputs gathered during the frame.
  29874. */
  29875. update(): void;
  29876. /** @hidden */ checkInputs(): void;
  29877. /** @hidden */
  29878. readonly rigCameras: Camera[];
  29879. /**
  29880. * Gets the post process used by the rig cameras
  29881. */
  29882. readonly rigPostProcess: Nullable<PostProcess>;
  29883. /**
  29884. * Internal, gets the first post proces.
  29885. * @returns the first post process to be run on this camera.
  29886. */ getFirstPostProcess(): Nullable<PostProcess>;
  29887. private _cascadePostProcessesToRigCams;
  29888. /**
  29889. * Attach a post process to the camera.
  29890. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29891. * @param postProcess The post process to attach to the camera
  29892. * @param insertAt The position of the post process in case several of them are in use in the scene
  29893. * @returns the position the post process has been inserted at
  29894. */
  29895. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29896. /**
  29897. * Detach a post process to the camera.
  29898. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29899. * @param postProcess The post process to detach from the camera
  29900. */
  29901. detachPostProcess(postProcess: PostProcess): void;
  29902. /**
  29903. * Gets the current world matrix of the camera
  29904. */
  29905. getWorldMatrix(): Matrix;
  29906. /** @hidden */ getViewMatrix(): Matrix;
  29907. /**
  29908. * Gets the current view matrix of the camera.
  29909. * @param force forces the camera to recompute the matrix without looking at the cached state
  29910. * @returns the view matrix
  29911. */
  29912. getViewMatrix(force?: boolean): Matrix;
  29913. /**
  29914. * Freeze the projection matrix.
  29915. * It will prevent the cache check of the camera projection compute and can speed up perf
  29916. * if no parameter of the camera are meant to change
  29917. * @param projection Defines manually a projection if necessary
  29918. */
  29919. freezeProjectionMatrix(projection?: Matrix): void;
  29920. /**
  29921. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29922. */
  29923. unfreezeProjectionMatrix(): void;
  29924. /**
  29925. * Gets the current projection matrix of the camera.
  29926. * @param force forces the camera to recompute the matrix without looking at the cached state
  29927. * @returns the projection matrix
  29928. */
  29929. getProjectionMatrix(force?: boolean): Matrix;
  29930. /**
  29931. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29932. * @returns a Matrix
  29933. */
  29934. getTransformationMatrix(): Matrix;
  29935. private _updateFrustumPlanes;
  29936. /**
  29937. * Checks if a cullable object (mesh...) is in the camera frustum
  29938. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29939. * @param target The object to check
  29940. * @returns true if the object is in frustum otherwise false
  29941. */
  29942. isInFrustum(target: ICullable): boolean;
  29943. /**
  29944. * Checks if a cullable object (mesh...) is in the camera frustum
  29945. * Unlike isInFrustum this cheks the full bounding box
  29946. * @param target The object to check
  29947. * @returns true if the object is in frustum otherwise false
  29948. */
  29949. isCompletelyInFrustum(target: ICullable): boolean;
  29950. /**
  29951. * Gets a ray in the forward direction from the camera.
  29952. * @param length Defines the length of the ray to create
  29953. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29954. * @param origin Defines the start point of the ray which defaults to the camera position
  29955. * @returns the forward ray
  29956. */
  29957. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29958. /**
  29959. * Releases resources associated with this node.
  29960. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29961. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29962. */
  29963. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29964. /** @hidden */ isLeftCamera: boolean;
  29965. /**
  29966. * Gets the left camera of a rig setup in case of Rigged Camera
  29967. */
  29968. readonly isLeftCamera: boolean;
  29969. /** @hidden */ isRightCamera: boolean;
  29970. /**
  29971. * Gets the right camera of a rig setup in case of Rigged Camera
  29972. */
  29973. readonly isRightCamera: boolean;
  29974. /**
  29975. * Gets the left camera of a rig setup in case of Rigged Camera
  29976. */
  29977. readonly leftCamera: Nullable<FreeCamera>;
  29978. /**
  29979. * Gets the right camera of a rig setup in case of Rigged Camera
  29980. */
  29981. readonly rightCamera: Nullable<FreeCamera>;
  29982. /**
  29983. * Gets the left camera target of a rig setup in case of Rigged Camera
  29984. * @returns the target position
  29985. */
  29986. getLeftTarget(): Nullable<Vector3>;
  29987. /**
  29988. * Gets the right camera target of a rig setup in case of Rigged Camera
  29989. * @returns the target position
  29990. */
  29991. getRightTarget(): Nullable<Vector3>;
  29992. /**
  29993. * @hidden
  29994. */
  29995. setCameraRigMode(mode: number, rigParams: any): void;
  29996. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  29997. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29998. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  29999. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30000. /** @hidden */ getVRProjectionMatrix(): Matrix;
  30001. protected _updateCameraRotationMatrix(): void;
  30002. protected _updateWebVRCameraRotationMatrix(): void;
  30003. /**
  30004. * This function MUST be overwritten by the different WebVR cameras available.
  30005. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30006. * @hidden
  30007. */ getWebVRProjectionMatrix(): Matrix;
  30008. /**
  30009. * This function MUST be overwritten by the different WebVR cameras available.
  30010. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30011. * @hidden
  30012. */ getWebVRViewMatrix(): Matrix;
  30013. /** @hidden */
  30014. setCameraRigParameter(name: string, value: any): void;
  30015. /**
  30016. * needs to be overridden by children so sub has required properties to be copied
  30017. * @hidden
  30018. */
  30019. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30020. /**
  30021. * May need to be overridden by children
  30022. * @hidden
  30023. */ updateRigCameras(): void;
  30024. /** @hidden */ setupInputs(): void;
  30025. /**
  30026. * Serialiaze the camera setup to a json represention
  30027. * @returns the JSON representation
  30028. */
  30029. serialize(): any;
  30030. /**
  30031. * Clones the current camera.
  30032. * @param name The cloned camera name
  30033. * @returns the cloned camera
  30034. */
  30035. clone(name: string): Camera;
  30036. /**
  30037. * Gets the direction of the camera relative to a given local axis.
  30038. * @param localAxis Defines the reference axis to provide a relative direction.
  30039. * @return the direction
  30040. */
  30041. getDirection(localAxis: Vector3): Vector3;
  30042. /**
  30043. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30044. * @param localAxis Defines the reference axis to provide a relative direction.
  30045. * @param result Defines the vector to store the result in
  30046. */
  30047. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30048. /**
  30049. * Gets a camera constructor for a given camera type
  30050. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30051. * @param name The name of the camera the result will be able to instantiate
  30052. * @param scene The scene the result will construct the camera in
  30053. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30054. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30055. * @returns a factory method to construc the camera
  30056. */
  30057. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30058. /**
  30059. * Compute the world matrix of the camera.
  30060. * @returns the camera workd matrix
  30061. */
  30062. computeWorldMatrix(): Matrix;
  30063. /**
  30064. * Parse a JSON and creates the camera from the parsed information
  30065. * @param parsedCamera The JSON to parse
  30066. * @param scene The scene to instantiate the camera in
  30067. * @returns the newly constructed camera
  30068. */
  30069. static Parse(parsedCamera: any, scene: Scene): Camera;
  30070. }
  30071. }
  30072. declare module BABYLON {
  30073. /**
  30074. * Interface for any object that can request an animation frame
  30075. */
  30076. export interface ICustomAnimationFrameRequester {
  30077. /**
  30078. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30079. */
  30080. renderFunction?: Function;
  30081. /**
  30082. * Called to request the next frame to render to
  30083. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30084. */
  30085. requestAnimationFrame: Function;
  30086. /**
  30087. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30088. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30089. */
  30090. requestID?: number;
  30091. }
  30092. /**
  30093. * Interface containing an array of animations
  30094. */
  30095. export interface IAnimatable {
  30096. /**
  30097. * Array of animations
  30098. */
  30099. animations: Nullable<Array<Animation>>;
  30100. }
  30101. /** Interface used by value gradients (color, factor, ...) */
  30102. export interface IValueGradient {
  30103. /**
  30104. * Gets or sets the gradient value (between 0 and 1)
  30105. */
  30106. gradient: number;
  30107. }
  30108. /** Class used to store color4 gradient */
  30109. export class ColorGradient implements IValueGradient {
  30110. /**
  30111. * Gets or sets the gradient value (between 0 and 1)
  30112. */
  30113. gradient: number;
  30114. /**
  30115. * Gets or sets first associated color
  30116. */
  30117. color1: Color4;
  30118. /**
  30119. * Gets or sets second associated color
  30120. */
  30121. color2?: Color4;
  30122. /**
  30123. * Will get a color picked randomly between color1 and color2.
  30124. * If color2 is undefined then color1 will be used
  30125. * @param result defines the target Color4 to store the result in
  30126. */
  30127. getColorToRef(result: Color4): void;
  30128. }
  30129. /** Class used to store color 3 gradient */
  30130. export class Color3Gradient implements IValueGradient {
  30131. /**
  30132. * Gets or sets the gradient value (between 0 and 1)
  30133. */
  30134. gradient: number;
  30135. /**
  30136. * Gets or sets the associated color
  30137. */
  30138. color: Color3;
  30139. }
  30140. /** Class used to store factor gradient */
  30141. export class FactorGradient implements IValueGradient {
  30142. /**
  30143. * Gets or sets the gradient value (between 0 and 1)
  30144. */
  30145. gradient: number;
  30146. /**
  30147. * Gets or sets first associated factor
  30148. */
  30149. factor1: number;
  30150. /**
  30151. * Gets or sets second associated factor
  30152. */
  30153. factor2?: number;
  30154. /**
  30155. * Will get a number picked randomly between factor1 and factor2.
  30156. * If factor2 is undefined then factor1 will be used
  30157. * @returns the picked number
  30158. */
  30159. getFactor(): number;
  30160. }
  30161. /**
  30162. * @ignore
  30163. * Application error to support additional information when loading a file
  30164. */
  30165. export class LoadFileError extends Error {
  30166. /** defines the optional web request */
  30167. request?: WebRequest | undefined;
  30168. private static _setPrototypeOf;
  30169. /**
  30170. * Creates a new LoadFileError
  30171. * @param message defines the message of the error
  30172. * @param request defines the optional web request
  30173. */
  30174. constructor(message: string,
  30175. /** defines the optional web request */
  30176. request?: WebRequest | undefined);
  30177. }
  30178. /**
  30179. * Class used to define a retry strategy when error happens while loading assets
  30180. */
  30181. export class RetryStrategy {
  30182. /**
  30183. * Function used to defines an exponential back off strategy
  30184. * @param maxRetries defines the maximum number of retries (3 by default)
  30185. * @param baseInterval defines the interval between retries
  30186. * @returns the strategy function to use
  30187. */
  30188. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30189. }
  30190. /**
  30191. * File request interface
  30192. */
  30193. export interface IFileRequest {
  30194. /**
  30195. * Raised when the request is complete (success or error).
  30196. */
  30197. onCompleteObservable: Observable<IFileRequest>;
  30198. /**
  30199. * Aborts the request for a file.
  30200. */
  30201. abort: () => void;
  30202. }
  30203. /**
  30204. * Class containing a set of static utilities functions
  30205. */
  30206. export class Tools {
  30207. /**
  30208. * Gets or sets the base URL to use to load assets
  30209. */
  30210. static BaseUrl: string;
  30211. /**
  30212. * Enable/Disable Custom HTTP Request Headers globally.
  30213. * default = false
  30214. * @see CustomRequestHeaders
  30215. */
  30216. static UseCustomRequestHeaders: boolean;
  30217. /**
  30218. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30219. * i.e. when loading files, where the server/service expects an Authorization header
  30220. */
  30221. static CustomRequestHeaders: {
  30222. [key: string]: string;
  30223. };
  30224. /**
  30225. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30226. */
  30227. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30228. /**
  30229. * Default behaviour for cors in the application.
  30230. * It can be a string if the expected behavior is identical in the entire app.
  30231. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30232. */
  30233. static CorsBehavior: string | ((url: string | string[]) => string);
  30234. /**
  30235. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30236. * @ignorenaming
  30237. */
  30238. static UseFallbackTexture: boolean;
  30239. /**
  30240. * Use this object to register external classes like custom textures or material
  30241. * to allow the laoders to instantiate them
  30242. */
  30243. static RegisteredExternalClasses: {
  30244. [key: string]: Object;
  30245. };
  30246. /**
  30247. * Texture content used if a texture cannot loaded
  30248. * @ignorenaming
  30249. */
  30250. static fallbackTexture: string;
  30251. /**
  30252. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30253. * @param u defines the coordinate on X axis
  30254. * @param v defines the coordinate on Y axis
  30255. * @param width defines the width of the source data
  30256. * @param height defines the height of the source data
  30257. * @param pixels defines the source byte array
  30258. * @param color defines the output color
  30259. */
  30260. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30261. /**
  30262. * Interpolates between a and b via alpha
  30263. * @param a The lower value (returned when alpha = 0)
  30264. * @param b The upper value (returned when alpha = 1)
  30265. * @param alpha The interpolation-factor
  30266. * @return The mixed value
  30267. */
  30268. static Mix(a: number, b: number, alpha: number): number;
  30269. /**
  30270. * Tries to instantiate a new object from a given class name
  30271. * @param className defines the class name to instantiate
  30272. * @returns the new object or null if the system was not able to do the instantiation
  30273. */
  30274. static Instantiate(className: string): any;
  30275. /**
  30276. * Provides a slice function that will work even on IE
  30277. * @param data defines the array to slice
  30278. * @param start defines the start of the data (optional)
  30279. * @param end defines the end of the data (optional)
  30280. * @returns the new sliced array
  30281. */
  30282. static Slice<T>(data: T, start?: number, end?: number): T;
  30283. /**
  30284. * Polyfill for setImmediate
  30285. * @param action defines the action to execute after the current execution block
  30286. */
  30287. static SetImmediate(action: () => void): void;
  30288. /**
  30289. * Function indicating if a number is an exponent of 2
  30290. * @param value defines the value to test
  30291. * @returns true if the value is an exponent of 2
  30292. */
  30293. static IsExponentOfTwo(value: number): boolean;
  30294. private static _tmpFloatArray;
  30295. /**
  30296. * Returns the nearest 32-bit single precision float representation of a Number
  30297. * @param value A Number. If the parameter is of a different type, it will get converted
  30298. * to a number or to NaN if it cannot be converted
  30299. * @returns number
  30300. */
  30301. static FloatRound(value: number): number;
  30302. /**
  30303. * Find the next highest power of two.
  30304. * @param x Number to start search from.
  30305. * @return Next highest power of two.
  30306. */
  30307. static CeilingPOT(x: number): number;
  30308. /**
  30309. * Find the next lowest power of two.
  30310. * @param x Number to start search from.
  30311. * @return Next lowest power of two.
  30312. */
  30313. static FloorPOT(x: number): number;
  30314. /**
  30315. * Find the nearest power of two.
  30316. * @param x Number to start search from.
  30317. * @return Next nearest power of two.
  30318. */
  30319. static NearestPOT(x: number): number;
  30320. /**
  30321. * Get the closest exponent of two
  30322. * @param value defines the value to approximate
  30323. * @param max defines the maximum value to return
  30324. * @param mode defines how to define the closest value
  30325. * @returns closest exponent of two of the given value
  30326. */
  30327. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30328. /**
  30329. * Extracts the filename from a path
  30330. * @param path defines the path to use
  30331. * @returns the filename
  30332. */
  30333. static GetFilename(path: string): string;
  30334. /**
  30335. * Extracts the "folder" part of a path (everything before the filename).
  30336. * @param uri The URI to extract the info from
  30337. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30338. * @returns The "folder" part of the path
  30339. */
  30340. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30341. /**
  30342. * Extracts text content from a DOM element hierarchy
  30343. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30344. */
  30345. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30346. /**
  30347. * Convert an angle in radians to degrees
  30348. * @param angle defines the angle to convert
  30349. * @returns the angle in degrees
  30350. */
  30351. static ToDegrees(angle: number): number;
  30352. /**
  30353. * Convert an angle in degrees to radians
  30354. * @param angle defines the angle to convert
  30355. * @returns the angle in radians
  30356. */
  30357. static ToRadians(angle: number): number;
  30358. /**
  30359. * Encode a buffer to a base64 string
  30360. * @param buffer defines the buffer to encode
  30361. * @returns the encoded string
  30362. */
  30363. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30364. /**
  30365. * Extracts minimum and maximum values from a list of indexed positions
  30366. * @param positions defines the positions to use
  30367. * @param indices defines the indices to the positions
  30368. * @param indexStart defines the start index
  30369. * @param indexCount defines the end index
  30370. * @param bias defines bias value to add to the result
  30371. * @return minimum and maximum values
  30372. */
  30373. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30374. minimum: Vector3;
  30375. maximum: Vector3;
  30376. };
  30377. /**
  30378. * Extracts minimum and maximum values from a list of positions
  30379. * @param positions defines the positions to use
  30380. * @param start defines the start index in the positions array
  30381. * @param count defines the number of positions to handle
  30382. * @param bias defines bias value to add to the result
  30383. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30384. * @return minimum and maximum values
  30385. */
  30386. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30387. minimum: Vector3;
  30388. maximum: Vector3;
  30389. };
  30390. /**
  30391. * Returns an array if obj is not an array
  30392. * @param obj defines the object to evaluate as an array
  30393. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30394. * @returns either obj directly if obj is an array or a new array containing obj
  30395. */
  30396. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30397. /**
  30398. * Gets the pointer prefix to use
  30399. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30400. */
  30401. static GetPointerPrefix(): string;
  30402. /**
  30403. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30404. * @param func - the function to be called
  30405. * @param requester - the object that will request the next frame. Falls back to window.
  30406. * @returns frame number
  30407. */
  30408. static QueueNewFrame(func: () => void, requester?: any): number;
  30409. /**
  30410. * Ask the browser to promote the current element to fullscreen rendering mode
  30411. * @param element defines the DOM element to promote
  30412. */
  30413. static RequestFullscreen(element: HTMLElement): void;
  30414. /**
  30415. * Asks the browser to exit fullscreen mode
  30416. */
  30417. static ExitFullscreen(): void;
  30418. /**
  30419. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30420. * @param url define the url we are trying
  30421. * @param element define the dom element where to configure the cors policy
  30422. */
  30423. static SetCorsBehavior(url: string | string[], element: {
  30424. crossOrigin: string | null;
  30425. }): void;
  30426. /**
  30427. * Removes unwanted characters from an url
  30428. * @param url defines the url to clean
  30429. * @returns the cleaned url
  30430. */
  30431. static CleanUrl(url: string): string;
  30432. /**
  30433. * Gets or sets a function used to pre-process url before using them to load assets
  30434. */
  30435. static PreprocessUrl: (url: string) => string;
  30436. /**
  30437. * Loads an image as an HTMLImageElement.
  30438. * @param input url string, ArrayBuffer, or Blob to load
  30439. * @param onLoad callback called when the image successfully loads
  30440. * @param onError callback called when the image fails to load
  30441. * @param offlineProvider offline provider for caching
  30442. * @returns the HTMLImageElement of the loaded image
  30443. */
  30444. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30445. /**
  30446. * Loads a file
  30447. * @param url url string, ArrayBuffer, or Blob to load
  30448. * @param onSuccess callback called when the file successfully loads
  30449. * @param onProgress callback called while file is loading (if the server supports this mode)
  30450. * @param offlineProvider defines the offline provider for caching
  30451. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30452. * @param onError callback called when the file fails to load
  30453. * @returns a file request object
  30454. */
  30455. 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;
  30456. /**
  30457. * Load a script (identified by an url). When the url returns, the
  30458. * content of this file is added into a new script element, attached to the DOM (body element)
  30459. * @param scriptUrl defines the url of the script to laod
  30460. * @param onSuccess defines the callback called when the script is loaded
  30461. * @param onError defines the callback to call if an error occurs
  30462. * @param scriptId defines the id of the script element
  30463. */
  30464. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30465. /**
  30466. * Load an asynchronous script (identified by an url). When the url returns, the
  30467. * content of this file is added into a new script element, attached to the DOM (body element)
  30468. * @param scriptUrl defines the url of the script to laod
  30469. * @param scriptId defines the id of the script element
  30470. * @returns a promise request object
  30471. */
  30472. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30473. /**
  30474. * Loads a file from a blob
  30475. * @param fileToLoad defines the blob to use
  30476. * @param callback defines the callback to call when data is loaded
  30477. * @param progressCallback defines the callback to call during loading process
  30478. * @returns a file request object
  30479. */
  30480. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30481. /**
  30482. * Loads a file
  30483. * @param fileToLoad defines the file to load
  30484. * @param callback defines the callback to call when data is loaded
  30485. * @param progressCallBack defines the callback to call during loading process
  30486. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30487. * @returns a file request object
  30488. */
  30489. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30490. /**
  30491. * Creates a data url from a given string content
  30492. * @param content defines the content to convert
  30493. * @returns the new data url link
  30494. */
  30495. static FileAsURL(content: string): string;
  30496. /**
  30497. * Format the given number to a specific decimal format
  30498. * @param value defines the number to format
  30499. * @param decimals defines the number of decimals to use
  30500. * @returns the formatted string
  30501. */
  30502. static Format(value: number, decimals?: number): string;
  30503. /**
  30504. * Checks if a given vector is inside a specific range
  30505. * @param v defines the vector to test
  30506. * @param min defines the minimum range
  30507. * @param max defines the maximum range
  30508. */
  30509. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30510. /**
  30511. * Tries to copy an object by duplicating every property
  30512. * @param source defines the source object
  30513. * @param destination defines the target object
  30514. * @param doNotCopyList defines a list of properties to avoid
  30515. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30516. */
  30517. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30518. /**
  30519. * Gets a boolean indicating if the given object has no own property
  30520. * @param obj defines the object to test
  30521. * @returns true if object has no own property
  30522. */
  30523. static IsEmpty(obj: any): boolean;
  30524. /**
  30525. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30526. * @param str Source string
  30527. * @param suffix Suffix to search for in the source string
  30528. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30529. */
  30530. static EndsWith(str: string, suffix: string): boolean;
  30531. /**
  30532. * Function used to register events at window level
  30533. * @param events defines the events to register
  30534. */
  30535. static RegisterTopRootEvents(events: {
  30536. name: string;
  30537. handler: Nullable<(e: FocusEvent) => any>;
  30538. }[]): void;
  30539. /**
  30540. * Function used to unregister events from window level
  30541. * @param events defines the events to unregister
  30542. */
  30543. static UnregisterTopRootEvents(events: {
  30544. name: string;
  30545. handler: Nullable<(e: FocusEvent) => any>;
  30546. }[]): void;
  30547. /**
  30548. * @ignore
  30549. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30550. /**
  30551. * Dumps the current bound framebuffer
  30552. * @param width defines the rendering width
  30553. * @param height defines the rendering height
  30554. * @param engine defines the hosting engine
  30555. * @param successCallback defines the callback triggered once the data are available
  30556. * @param mimeType defines the mime type of the result
  30557. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30558. */
  30559. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30560. /**
  30561. * Converts the canvas data to blob.
  30562. * This acts as a polyfill for browsers not supporting the to blob function.
  30563. * @param canvas Defines the canvas to extract the data from
  30564. * @param successCallback Defines the callback triggered once the data are available
  30565. * @param mimeType Defines the mime type of the result
  30566. */
  30567. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30568. /**
  30569. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30570. * @param successCallback defines the callback triggered once the data are available
  30571. * @param mimeType defines the mime type of the result
  30572. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30573. */
  30574. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30575. /**
  30576. * Downloads a blob in the browser
  30577. * @param blob defines the blob to download
  30578. * @param fileName defines the name of the downloaded file
  30579. */
  30580. static Download(blob: Blob, fileName: string): void;
  30581. /**
  30582. * Captures a screenshot of the current rendering
  30583. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30584. * @param engine defines the rendering engine
  30585. * @param camera defines the source camera
  30586. * @param size This parameter can be set to a single number or to an object with the
  30587. * following (optional) properties: precision, width, height. If a single number is passed,
  30588. * it will be used for both width and height. If an object is passed, the screenshot size
  30589. * will be derived from the parameters. The precision property is a multiplier allowing
  30590. * rendering at a higher or lower resolution
  30591. * @param successCallback defines the callback receives a single parameter which contains the
  30592. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30593. * src parameter of an <img> to display it
  30594. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30595. * Check your browser for supported MIME types
  30596. */
  30597. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30598. /**
  30599. * Generates an image screenshot from the specified camera.
  30600. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30601. * @param engine The engine to use for rendering
  30602. * @param camera The camera to use for rendering
  30603. * @param size This parameter can be set to a single number or to an object with the
  30604. * following (optional) properties: precision, width, height. If a single number is passed,
  30605. * it will be used for both width and height. If an object is passed, the screenshot size
  30606. * will be derived from the parameters. The precision property is a multiplier allowing
  30607. * rendering at a higher or lower resolution
  30608. * @param successCallback The callback receives a single parameter which contains the
  30609. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30610. * src parameter of an <img> to display it
  30611. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30612. * Check your browser for supported MIME types
  30613. * @param samples Texture samples (default: 1)
  30614. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30615. * @param fileName A name for for the downloaded file.
  30616. */
  30617. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30618. /**
  30619. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30620. * Be aware Math.random() could cause collisions, but:
  30621. * "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"
  30622. * @returns a pseudo random id
  30623. */
  30624. static RandomId(): string;
  30625. /**
  30626. * Test if the given uri is a base64 string
  30627. * @param uri The uri to test
  30628. * @return True if the uri is a base64 string or false otherwise
  30629. */
  30630. static IsBase64(uri: string): boolean;
  30631. /**
  30632. * Decode the given base64 uri.
  30633. * @param uri The uri to decode
  30634. * @return The decoded base64 data.
  30635. */
  30636. static DecodeBase64(uri: string): ArrayBuffer;
  30637. /**
  30638. * Gets the absolute url.
  30639. * @param url the input url
  30640. * @return the absolute url
  30641. */
  30642. static GetAbsoluteUrl(url: string): string;
  30643. /**
  30644. * No log
  30645. */
  30646. static readonly NoneLogLevel: number;
  30647. /**
  30648. * Only message logs
  30649. */
  30650. static readonly MessageLogLevel: number;
  30651. /**
  30652. * Only warning logs
  30653. */
  30654. static readonly WarningLogLevel: number;
  30655. /**
  30656. * Only error logs
  30657. */
  30658. static readonly ErrorLogLevel: number;
  30659. /**
  30660. * All logs
  30661. */
  30662. static readonly AllLogLevel: number;
  30663. /**
  30664. * Gets a value indicating the number of loading errors
  30665. * @ignorenaming
  30666. */
  30667. static readonly errorsCount: number;
  30668. /**
  30669. * Callback called when a new log is added
  30670. */
  30671. static OnNewCacheEntry: (entry: string) => void;
  30672. /**
  30673. * Log a message to the console
  30674. * @param message defines the message to log
  30675. */
  30676. static Log(message: string): void;
  30677. /**
  30678. * Write a warning message to the console
  30679. * @param message defines the message to log
  30680. */
  30681. static Warn(message: string): void;
  30682. /**
  30683. * Write an error message to the console
  30684. * @param message defines the message to log
  30685. */
  30686. static Error(message: string): void;
  30687. /**
  30688. * Gets current log cache (list of logs)
  30689. */
  30690. static readonly LogCache: string;
  30691. /**
  30692. * Clears the log cache
  30693. */
  30694. static ClearLogCache(): void;
  30695. /**
  30696. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30697. */
  30698. static LogLevels: number;
  30699. /**
  30700. * Checks if the loaded document was accessed via `file:`-Protocol.
  30701. * @returns boolean
  30702. */
  30703. static IsFileURL(): boolean;
  30704. /**
  30705. * Checks if the window object exists
  30706. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30707. */
  30708. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30709. /**
  30710. * No performance log
  30711. */
  30712. static readonly PerformanceNoneLogLevel: number;
  30713. /**
  30714. * Use user marks to log performance
  30715. */
  30716. static readonly PerformanceUserMarkLogLevel: number;
  30717. /**
  30718. * Log performance to the console
  30719. */
  30720. static readonly PerformanceConsoleLogLevel: number;
  30721. private static _performance;
  30722. /**
  30723. * Sets the current performance log level
  30724. */
  30725. static PerformanceLogLevel: number;
  30726. private static _StartPerformanceCounterDisabled;
  30727. private static _EndPerformanceCounterDisabled;
  30728. private static _StartUserMark;
  30729. private static _EndUserMark;
  30730. private static _StartPerformanceConsole;
  30731. private static _EndPerformanceConsole;
  30732. /**
  30733. * Starts a performance counter
  30734. */
  30735. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30736. /**
  30737. * Ends a specific performance coutner
  30738. */
  30739. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30740. /**
  30741. * Gets either window.performance.now() if supported or Date.now() else
  30742. */
  30743. static readonly Now: number;
  30744. /**
  30745. * This method will return the name of the class used to create the instance of the given object.
  30746. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30747. * @param object the object to get the class name from
  30748. * @param isType defines if the object is actually a type
  30749. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30750. */
  30751. static GetClassName(object: any, isType?: boolean): string;
  30752. /**
  30753. * Gets the first element of an array satisfying a given predicate
  30754. * @param array defines the array to browse
  30755. * @param predicate defines the predicate to use
  30756. * @returns null if not found or the element
  30757. */
  30758. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30759. /**
  30760. * This method will return the name of the full name of the class, including its owning module (if any).
  30761. * 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).
  30762. * @param object the object to get the class name from
  30763. * @param isType defines if the object is actually a type
  30764. * @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.
  30765. * @ignorenaming
  30766. */
  30767. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30768. /**
  30769. * Returns a promise that resolves after the given amount of time.
  30770. * @param delay Number of milliseconds to delay
  30771. * @returns Promise that resolves after the given amount of time
  30772. */
  30773. static DelayAsync(delay: number): Promise<void>;
  30774. /**
  30775. * Gets the current gradient from an array of IValueGradient
  30776. * @param ratio defines the current ratio to get
  30777. * @param gradients defines the array of IValueGradient
  30778. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30779. */
  30780. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30781. }
  30782. /**
  30783. * This class is used to track a performance counter which is number based.
  30784. * The user has access to many properties which give statistics of different nature.
  30785. *
  30786. * The implementer can track two kinds of Performance Counter: time and count.
  30787. * 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.
  30788. * 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.
  30789. */
  30790. export class PerfCounter {
  30791. /**
  30792. * Gets or sets a global boolean to turn on and off all the counters
  30793. */
  30794. static Enabled: boolean;
  30795. /**
  30796. * Returns the smallest value ever
  30797. */
  30798. readonly min: number;
  30799. /**
  30800. * Returns the biggest value ever
  30801. */
  30802. readonly max: number;
  30803. /**
  30804. * Returns the average value since the performance counter is running
  30805. */
  30806. readonly average: number;
  30807. /**
  30808. * Returns the average value of the last second the counter was monitored
  30809. */
  30810. readonly lastSecAverage: number;
  30811. /**
  30812. * Returns the current value
  30813. */
  30814. readonly current: number;
  30815. /**
  30816. * Gets the accumulated total
  30817. */
  30818. readonly total: number;
  30819. /**
  30820. * Gets the total value count
  30821. */
  30822. readonly count: number;
  30823. /**
  30824. * Creates a new counter
  30825. */
  30826. constructor();
  30827. /**
  30828. * Call this method to start monitoring a new frame.
  30829. * 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.
  30830. */
  30831. fetchNewFrame(): void;
  30832. /**
  30833. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30834. * @param newCount the count value to add to the monitored count
  30835. * @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.
  30836. */
  30837. addCount(newCount: number, fetchResult: boolean): void;
  30838. /**
  30839. * Start monitoring this performance counter
  30840. */
  30841. beginMonitoring(): void;
  30842. /**
  30843. * Compute the time lapsed since the previous beginMonitoring() call.
  30844. * @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
  30845. */
  30846. endMonitoring(newFrame?: boolean): void;
  30847. private _fetchResult;
  30848. private _startMonitoringTime;
  30849. private _min;
  30850. private _max;
  30851. private _average;
  30852. private _current;
  30853. private _totalValueCount;
  30854. private _totalAccumulated;
  30855. private _lastSecAverage;
  30856. private _lastSecAccumulated;
  30857. private _lastSecTime;
  30858. private _lastSecValueCount;
  30859. }
  30860. /**
  30861. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30862. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30863. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30864. * @param name The name of the class, case should be preserved
  30865. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30866. */
  30867. export function className(name: string, module?: string): (target: Object) => void;
  30868. /**
  30869. * An implementation of a loop for asynchronous functions.
  30870. */
  30871. export class AsyncLoop {
  30872. /**
  30873. * Defines the number of iterations for the loop
  30874. */
  30875. iterations: number;
  30876. /**
  30877. * Defines the current index of the loop.
  30878. */
  30879. index: number;
  30880. private _done;
  30881. private _fn;
  30882. private _successCallback;
  30883. /**
  30884. * Constructor.
  30885. * @param iterations the number of iterations.
  30886. * @param func the function to run each iteration
  30887. * @param successCallback the callback that will be called upon succesful execution
  30888. * @param offset starting offset.
  30889. */
  30890. constructor(
  30891. /**
  30892. * Defines the number of iterations for the loop
  30893. */
  30894. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30895. /**
  30896. * Execute the next iteration. Must be called after the last iteration was finished.
  30897. */
  30898. executeNext(): void;
  30899. /**
  30900. * Break the loop and run the success callback.
  30901. */
  30902. breakLoop(): void;
  30903. /**
  30904. * Create and run an async loop.
  30905. * @param iterations the number of iterations.
  30906. * @param fn the function to run each iteration
  30907. * @param successCallback the callback that will be called upon succesful execution
  30908. * @param offset starting offset.
  30909. * @returns the created async loop object
  30910. */
  30911. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30912. /**
  30913. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30914. * @param iterations total number of iterations
  30915. * @param syncedIterations number of synchronous iterations in each async iteration.
  30916. * @param fn the function to call each iteration.
  30917. * @param callback a success call back that will be called when iterating stops.
  30918. * @param breakFunction a break condition (optional)
  30919. * @param timeout timeout settings for the setTimeout function. default - 0.
  30920. * @returns the created async loop object
  30921. */
  30922. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30923. }
  30924. }
  30925. declare module BABYLON {
  30926. /** @hidden */
  30927. export interface ICollisionCoordinator {
  30928. createCollider(): Collider;
  30929. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30930. init(scene: Scene): void;
  30931. }
  30932. /** @hidden */
  30933. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30934. private _scene;
  30935. private _scaledPosition;
  30936. private _scaledVelocity;
  30937. private _finalPosition;
  30938. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30939. createCollider(): Collider;
  30940. init(scene: Scene): void;
  30941. private _collideWithWorld;
  30942. }
  30943. }
  30944. declare module BABYLON {
  30945. /**
  30946. * Class used to manage all inputs for the scene.
  30947. */
  30948. export class InputManager {
  30949. /** The distance in pixel that you have to move to prevent some events */
  30950. static DragMovementThreshold: number;
  30951. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  30952. static LongPressDelay: number;
  30953. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  30954. static DoubleClickDelay: number;
  30955. /** If you need to check double click without raising a single click at first click, enable this flag */
  30956. static ExclusiveDoubleClickMode: boolean;
  30957. private _wheelEventName;
  30958. private _onPointerMove;
  30959. private _onPointerDown;
  30960. private _onPointerUp;
  30961. private _initClickEvent;
  30962. private _initActionManager;
  30963. private _delayedSimpleClick;
  30964. private _delayedSimpleClickTimeout;
  30965. private _previousDelayedSimpleClickTimeout;
  30966. private _meshPickProceed;
  30967. private _previousButtonPressed;
  30968. private _currentPickResult;
  30969. private _previousPickResult;
  30970. private _totalPointersPressed;
  30971. private _doubleClickOccured;
  30972. private _pointerOverMesh;
  30973. private _pickedDownMesh;
  30974. private _pickedUpMesh;
  30975. private _pointerX;
  30976. private _pointerY;
  30977. private _unTranslatedPointerX;
  30978. private _unTranslatedPointerY;
  30979. private _startingPointerPosition;
  30980. private _previousStartingPointerPosition;
  30981. private _startingPointerTime;
  30982. private _previousStartingPointerTime;
  30983. private _pointerCaptures;
  30984. private _onKeyDown;
  30985. private _onKeyUp;
  30986. private _onCanvasFocusObserver;
  30987. private _onCanvasBlurObserver;
  30988. private _scene;
  30989. /**
  30990. * Creates a new InputManager
  30991. * @param scene defines the hosting scene
  30992. */
  30993. constructor(scene: Scene);
  30994. /**
  30995. * Gets the mesh that is currently under the pointer
  30996. */
  30997. readonly meshUnderPointer: Nullable<AbstractMesh>;
  30998. /**
  30999. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31000. */
  31001. readonly unTranslatedPointer: Vector2;
  31002. /**
  31003. * Gets or sets the current on-screen X position of the pointer
  31004. */
  31005. pointerX: number;
  31006. /**
  31007. * Gets or sets the current on-screen Y position of the pointer
  31008. */
  31009. pointerY: number;
  31010. private _updatePointerPosition;
  31011. private _processPointerMove;
  31012. private _setRayOnPointerInfo;
  31013. private _checkPrePointerObservable;
  31014. /**
  31015. * Use this method to simulate a pointer move on a mesh
  31016. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31017. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31018. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31019. */
  31020. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31021. /**
  31022. * Use this method to simulate a pointer down on a mesh
  31023. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31024. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31025. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31026. */
  31027. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31028. private _processPointerDown;
  31029. /** @hidden */ isPointerSwiping(): boolean;
  31030. /**
  31031. * Use this method to simulate a pointer up on a mesh
  31032. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31033. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31034. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31035. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31036. */
  31037. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31038. private _processPointerUp;
  31039. /**
  31040. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31041. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31042. * @returns true if the pointer was captured
  31043. */
  31044. isPointerCaptured(pointerId?: number): boolean;
  31045. /**
  31046. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31047. * @param attachUp defines if you want to attach events to pointerup
  31048. * @param attachDown defines if you want to attach events to pointerdown
  31049. * @param attachMove defines if you want to attach events to pointermove
  31050. */
  31051. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31052. /**
  31053. * Detaches all event handlers
  31054. */
  31055. detachControl(): void;
  31056. /**
  31057. * Force the value of meshUnderPointer
  31058. * @param mesh defines the mesh to use
  31059. */
  31060. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31061. /**
  31062. * Gets the mesh under the pointer
  31063. * @returns a Mesh or null if no mesh is under the pointer
  31064. */
  31065. getPointerOverMesh(): Nullable<AbstractMesh>;
  31066. }
  31067. }
  31068. declare module BABYLON {
  31069. /**
  31070. * This class defines the direct association between an animation and a target
  31071. */
  31072. export class TargetedAnimation {
  31073. /**
  31074. * Animation to perform
  31075. */
  31076. animation: Animation;
  31077. /**
  31078. * Target to animate
  31079. */
  31080. target: any;
  31081. }
  31082. /**
  31083. * Use this class to create coordinated animations on multiple targets
  31084. */
  31085. export class AnimationGroup implements IDisposable {
  31086. /** The name of the animation group */
  31087. name: string;
  31088. private _scene;
  31089. private _targetedAnimations;
  31090. private _animatables;
  31091. private _from;
  31092. private _to;
  31093. private _isStarted;
  31094. private _isPaused;
  31095. private _speedRatio;
  31096. /**
  31097. * Gets or sets the unique id of the node
  31098. */
  31099. uniqueId: number;
  31100. /**
  31101. * This observable will notify when one animation have ended
  31102. */
  31103. onAnimationEndObservable: Observable<TargetedAnimation>;
  31104. /**
  31105. * Observer raised when one animation loops
  31106. */
  31107. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31108. /**
  31109. * This observable will notify when all animations have ended.
  31110. */
  31111. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31112. /**
  31113. * This observable will notify when all animations have paused.
  31114. */
  31115. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31116. /**
  31117. * This observable will notify when all animations are playing.
  31118. */
  31119. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31120. /**
  31121. * Gets the first frame
  31122. */
  31123. readonly from: number;
  31124. /**
  31125. * Gets the last frame
  31126. */
  31127. readonly to: number;
  31128. /**
  31129. * Define if the animations are started
  31130. */
  31131. readonly isStarted: boolean;
  31132. /**
  31133. * Gets a value indicating that the current group is playing
  31134. */
  31135. readonly isPlaying: boolean;
  31136. /**
  31137. * Gets or sets the speed ratio to use for all animations
  31138. */
  31139. /**
  31140. * Gets or sets the speed ratio to use for all animations
  31141. */
  31142. speedRatio: number;
  31143. /**
  31144. * Gets the targeted animations for this animation group
  31145. */
  31146. readonly targetedAnimations: Array<TargetedAnimation>;
  31147. /**
  31148. * returning the list of animatables controlled by this animation group.
  31149. */
  31150. readonly animatables: Array<Animatable>;
  31151. /**
  31152. * Instantiates a new Animation Group.
  31153. * This helps managing several animations at once.
  31154. * @see http://doc.babylonjs.com/how_to/group
  31155. * @param name Defines the name of the group
  31156. * @param scene Defines the scene the group belongs to
  31157. */
  31158. constructor(
  31159. /** The name of the animation group */
  31160. name: string, scene?: Nullable<Scene>);
  31161. /**
  31162. * Add an animation (with its target) in the group
  31163. * @param animation defines the animation we want to add
  31164. * @param target defines the target of the animation
  31165. * @returns the TargetedAnimation object
  31166. */
  31167. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31168. /**
  31169. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31170. * It can add constant keys at begin or end
  31171. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31172. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31173. * @returns the animation group
  31174. */
  31175. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31176. /**
  31177. * Start all animations on given targets
  31178. * @param loop defines if animations must loop
  31179. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31180. * @param from defines the from key (optional)
  31181. * @param to defines the to key (optional)
  31182. * @returns the current animation group
  31183. */
  31184. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31185. /**
  31186. * Pause all animations
  31187. * @returns the animation group
  31188. */
  31189. pause(): AnimationGroup;
  31190. /**
  31191. * Play all animations to initial state
  31192. * This function will start() the animations if they were not started or will restart() them if they were paused
  31193. * @param loop defines if animations must loop
  31194. * @returns the animation group
  31195. */
  31196. play(loop?: boolean): AnimationGroup;
  31197. /**
  31198. * Reset all animations to initial state
  31199. * @returns the animation group
  31200. */
  31201. reset(): AnimationGroup;
  31202. /**
  31203. * Restart animations from key 0
  31204. * @returns the animation group
  31205. */
  31206. restart(): AnimationGroup;
  31207. /**
  31208. * Stop all animations
  31209. * @returns the animation group
  31210. */
  31211. stop(): AnimationGroup;
  31212. /**
  31213. * Set animation weight for all animatables
  31214. * @param weight defines the weight to use
  31215. * @return the animationGroup
  31216. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31217. */
  31218. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31219. /**
  31220. * Synchronize and normalize all animatables with a source animatable
  31221. * @param root defines the root animatable to synchronize with
  31222. * @return the animationGroup
  31223. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31224. */
  31225. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31226. /**
  31227. * Goes to a specific frame in this animation group
  31228. * @param frame the frame number to go to
  31229. * @return the animationGroup
  31230. */
  31231. goToFrame(frame: number): AnimationGroup;
  31232. /**
  31233. * Dispose all associated resources
  31234. */
  31235. dispose(): void;
  31236. private _checkAnimationGroupEnded;
  31237. /**
  31238. * Clone the current animation group and returns a copy
  31239. * @param newName defines the name of the new group
  31240. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31241. * @returns the new aniamtion group
  31242. */
  31243. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31244. /**
  31245. * Returns a new AnimationGroup object parsed from the source provided.
  31246. * @param parsedAnimationGroup defines the source
  31247. * @param scene defines the scene that will receive the animationGroup
  31248. * @returns a new AnimationGroup
  31249. */
  31250. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31251. /**
  31252. * Returns the string "AnimationGroup"
  31253. * @returns "AnimationGroup"
  31254. */
  31255. getClassName(): string;
  31256. /**
  31257. * Creates a detailled string about the object
  31258. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31259. * @returns a string representing the object
  31260. */
  31261. toString(fullDetails?: boolean): string;
  31262. }
  31263. }
  31264. declare module BABYLON {
  31265. /**
  31266. * Define an interface for all classes that will hold resources
  31267. */
  31268. export interface IDisposable {
  31269. /**
  31270. * Releases all held resources
  31271. */
  31272. dispose(): void;
  31273. }
  31274. /** Interface defining initialization parameters for Scene class */
  31275. export interface SceneOptions {
  31276. /**
  31277. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31278. * It will improve performance when the number of geometries becomes important.
  31279. */
  31280. useGeometryUniqueIdsMap?: boolean;
  31281. /**
  31282. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31283. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31284. */
  31285. useMaterialMeshMap?: boolean;
  31286. /**
  31287. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31288. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31289. */
  31290. useClonedMeshhMap?: boolean;
  31291. }
  31292. /**
  31293. * Represents a scene to be rendered by the engine.
  31294. * @see http://doc.babylonjs.com/features/scene
  31295. */
  31296. export class Scene extends AbstractScene implements IAnimatable {
  31297. private static _uniqueIdCounter;
  31298. /** The fog is deactivated */
  31299. static readonly FOGMODE_NONE: number;
  31300. /** The fog density is following an exponential function */
  31301. static readonly FOGMODE_EXP: number;
  31302. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31303. static readonly FOGMODE_EXP2: number;
  31304. /** The fog density is following a linear function. */
  31305. static readonly FOGMODE_LINEAR: number;
  31306. /**
  31307. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31308. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31309. */
  31310. static MinDeltaTime: number;
  31311. /**
  31312. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31313. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31314. */
  31315. static MaxDeltaTime: number;
  31316. /**
  31317. * Factory used to create the default material.
  31318. * @param name The name of the material to create
  31319. * @param scene The scene to create the material for
  31320. * @returns The default material
  31321. */
  31322. static DefaultMaterialFactory(scene: Scene): Material;
  31323. /**
  31324. * Factory used to create the a collision coordinator.
  31325. * @returns The collision coordinator
  31326. */
  31327. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31328. /** @hidden */ inputManager: InputManager;
  31329. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31330. cameraToUseForPointers: Nullable<Camera>;
  31331. /** @hidden */ protected readonly _isScene: boolean;
  31332. /**
  31333. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31334. */
  31335. autoClear: boolean;
  31336. /**
  31337. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31338. */
  31339. autoClearDepthAndStencil: boolean;
  31340. /**
  31341. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31342. */
  31343. clearColor: Color4;
  31344. /**
  31345. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31346. */
  31347. ambientColor: Color3;
  31348. /**
  31349. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31350. * It should only be one of the following (if not the default embedded one):
  31351. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31352. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31353. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31354. * The material properties need to be setup according to the type of texture in use.
  31355. */
  31356. environmentBRDFTexture: BaseTexture;
  31357. /** @hidden */
  31358. protected _environmentTexture: Nullable<BaseTexture>;
  31359. /**
  31360. * Texture used in all pbr material as the reflection texture.
  31361. * As in the majority of the scene they are the same (exception for multi room and so on),
  31362. * this is easier to reference from here than from all the materials.
  31363. */
  31364. /**
  31365. * Texture used in all pbr material as the reflection texture.
  31366. * As in the majority of the scene they are the same (exception for multi room and so on),
  31367. * this is easier to set here than in all the materials.
  31368. */
  31369. environmentTexture: Nullable<BaseTexture>;
  31370. /** @hidden */
  31371. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31372. /**
  31373. * Default image processing configuration used either in the rendering
  31374. * Forward main pass or through the imageProcessingPostProcess if present.
  31375. * As in the majority of the scene they are the same (exception for multi camera),
  31376. * this is easier to reference from here than from all the materials and post process.
  31377. *
  31378. * No setter as we it is a shared configuration, you can set the values instead.
  31379. */
  31380. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31381. private _forceWireframe;
  31382. /**
  31383. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31384. */
  31385. forceWireframe: boolean;
  31386. private _forcePointsCloud;
  31387. /**
  31388. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31389. */
  31390. forcePointsCloud: boolean;
  31391. /**
  31392. * Gets or sets the active clipplane 1
  31393. */
  31394. clipPlane: Nullable<Plane>;
  31395. /**
  31396. * Gets or sets the active clipplane 2
  31397. */
  31398. clipPlane2: Nullable<Plane>;
  31399. /**
  31400. * Gets or sets the active clipplane 3
  31401. */
  31402. clipPlane3: Nullable<Plane>;
  31403. /**
  31404. * Gets or sets the active clipplane 4
  31405. */
  31406. clipPlane4: Nullable<Plane>;
  31407. /**
  31408. * Gets or sets a boolean indicating if animations are enabled
  31409. */
  31410. animationsEnabled: boolean;
  31411. private _animationPropertiesOverride;
  31412. /**
  31413. * Gets or sets the animation properties override
  31414. */
  31415. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31416. /**
  31417. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31418. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31419. */
  31420. useConstantAnimationDeltaTime: boolean;
  31421. /**
  31422. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31423. * Please note that it requires to run a ray cast through the scene on every frame
  31424. */
  31425. constantlyUpdateMeshUnderPointer: boolean;
  31426. /**
  31427. * Defines the HTML cursor to use when hovering over interactive elements
  31428. */
  31429. hoverCursor: string;
  31430. /**
  31431. * Defines the HTML default cursor to use (empty by default)
  31432. */
  31433. defaultCursor: string;
  31434. /**
  31435. * This is used to call preventDefault() on pointer down
  31436. * in order to block unwanted artifacts like system double clicks
  31437. */
  31438. preventDefaultOnPointerDown: boolean;
  31439. /**
  31440. * This is used to call preventDefault() on pointer up
  31441. * in order to block unwanted artifacts like system double clicks
  31442. */
  31443. preventDefaultOnPointerUp: boolean;
  31444. /**
  31445. * Gets or sets user defined metadata
  31446. */
  31447. metadata: any;
  31448. /**
  31449. * For internal use only. Please do not use.
  31450. */
  31451. reservedDataStore: any;
  31452. /**
  31453. * Gets the name of the plugin used to load this scene (null by default)
  31454. */
  31455. loadingPluginName: string;
  31456. /**
  31457. * Use this array to add regular expressions used to disable offline support for specific urls
  31458. */
  31459. disableOfflineSupportExceptionRules: RegExp[];
  31460. /**
  31461. * An event triggered when the scene is disposed.
  31462. */
  31463. onDisposeObservable: Observable<Scene>;
  31464. private _onDisposeObserver;
  31465. /** Sets a function to be executed when this scene is disposed. */
  31466. onDispose: () => void;
  31467. /**
  31468. * An event triggered before rendering the scene (right after animations and physics)
  31469. */
  31470. onBeforeRenderObservable: Observable<Scene>;
  31471. private _onBeforeRenderObserver;
  31472. /** Sets a function to be executed before rendering this scene */
  31473. beforeRender: Nullable<() => void>;
  31474. /**
  31475. * An event triggered after rendering the scene
  31476. */
  31477. onAfterRenderObservable: Observable<Scene>;
  31478. private _onAfterRenderObserver;
  31479. /** Sets a function to be executed after rendering this scene */
  31480. afterRender: Nullable<() => void>;
  31481. /**
  31482. * An event triggered before animating the scene
  31483. */
  31484. onBeforeAnimationsObservable: Observable<Scene>;
  31485. /**
  31486. * An event triggered after animations processing
  31487. */
  31488. onAfterAnimationsObservable: Observable<Scene>;
  31489. /**
  31490. * An event triggered before draw calls are ready to be sent
  31491. */
  31492. onBeforeDrawPhaseObservable: Observable<Scene>;
  31493. /**
  31494. * An event triggered after draw calls have been sent
  31495. */
  31496. onAfterDrawPhaseObservable: Observable<Scene>;
  31497. /**
  31498. * An event triggered when the scene is ready
  31499. */
  31500. onReadyObservable: Observable<Scene>;
  31501. /**
  31502. * An event triggered before rendering a camera
  31503. */
  31504. onBeforeCameraRenderObservable: Observable<Camera>;
  31505. private _onBeforeCameraRenderObserver;
  31506. /** Sets a function to be executed before rendering a camera*/
  31507. beforeCameraRender: () => void;
  31508. /**
  31509. * An event triggered after rendering a camera
  31510. */
  31511. onAfterCameraRenderObservable: Observable<Camera>;
  31512. private _onAfterCameraRenderObserver;
  31513. /** Sets a function to be executed after rendering a camera*/
  31514. afterCameraRender: () => void;
  31515. /**
  31516. * An event triggered when active meshes evaluation is about to start
  31517. */
  31518. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31519. /**
  31520. * An event triggered when active meshes evaluation is done
  31521. */
  31522. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31523. /**
  31524. * An event triggered when particles rendering is about to start
  31525. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31526. */
  31527. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31528. /**
  31529. * An event triggered when particles rendering is done
  31530. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31531. */
  31532. onAfterParticlesRenderingObservable: Observable<Scene>;
  31533. /**
  31534. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31535. */
  31536. onDataLoadedObservable: Observable<Scene>;
  31537. /**
  31538. * An event triggered when a camera is created
  31539. */
  31540. onNewCameraAddedObservable: Observable<Camera>;
  31541. /**
  31542. * An event triggered when a camera is removed
  31543. */
  31544. onCameraRemovedObservable: Observable<Camera>;
  31545. /**
  31546. * An event triggered when a light is created
  31547. */
  31548. onNewLightAddedObservable: Observable<Light>;
  31549. /**
  31550. * An event triggered when a light is removed
  31551. */
  31552. onLightRemovedObservable: Observable<Light>;
  31553. /**
  31554. * An event triggered when a geometry is created
  31555. */
  31556. onNewGeometryAddedObservable: Observable<Geometry>;
  31557. /**
  31558. * An event triggered when a geometry is removed
  31559. */
  31560. onGeometryRemovedObservable: Observable<Geometry>;
  31561. /**
  31562. * An event triggered when a transform node is created
  31563. */
  31564. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31565. /**
  31566. * An event triggered when a transform node is removed
  31567. */
  31568. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31569. /**
  31570. * An event triggered when a mesh is created
  31571. */
  31572. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31573. /**
  31574. * An event triggered when a mesh is removed
  31575. */
  31576. onMeshRemovedObservable: Observable<AbstractMesh>;
  31577. /**
  31578. * An event triggered when a skeleton is created
  31579. */
  31580. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31581. /**
  31582. * An event triggered when a skeleton is removed
  31583. */
  31584. onSkeletonRemovedObservable: Observable<Skeleton>;
  31585. /**
  31586. * An event triggered when a material is created
  31587. */
  31588. onNewMaterialAddedObservable: Observable<Material>;
  31589. /**
  31590. * An event triggered when a material is removed
  31591. */
  31592. onMaterialRemovedObservable: Observable<Material>;
  31593. /**
  31594. * An event triggered when a texture is created
  31595. */
  31596. onNewTextureAddedObservable: Observable<BaseTexture>;
  31597. /**
  31598. * An event triggered when a texture is removed
  31599. */
  31600. onTextureRemovedObservable: Observable<BaseTexture>;
  31601. /**
  31602. * An event triggered when render targets are about to be rendered
  31603. * Can happen multiple times per frame.
  31604. */
  31605. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31606. /**
  31607. * An event triggered when render targets were rendered.
  31608. * Can happen multiple times per frame.
  31609. */
  31610. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31611. /**
  31612. * An event triggered before calculating deterministic simulation step
  31613. */
  31614. onBeforeStepObservable: Observable<Scene>;
  31615. /**
  31616. * An event triggered after calculating deterministic simulation step
  31617. */
  31618. onAfterStepObservable: Observable<Scene>;
  31619. /**
  31620. * An event triggered when the activeCamera property is updated
  31621. */
  31622. onActiveCameraChanged: Observable<Scene>;
  31623. /**
  31624. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31625. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31626. * 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)
  31627. */
  31628. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31629. /**
  31630. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31631. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31632. * 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)
  31633. */
  31634. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31635. /**
  31636. * This Observable will when a mesh has been imported into the scene.
  31637. */
  31638. onMeshImportedObservable: Observable<AbstractMesh>;
  31639. /**
  31640. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31641. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31642. */
  31643. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31644. /** @hidden */ registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31645. /**
  31646. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31647. */
  31648. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31649. /**
  31650. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31651. */
  31652. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31653. /**
  31654. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31655. */
  31656. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31657. /** Callback called when a pointer move is detected */
  31658. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31659. /** Callback called when a pointer down is detected */
  31660. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31661. /** Callback called when a pointer up is detected */
  31662. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31663. /** Callback called when a pointer pick is detected */
  31664. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31665. /**
  31666. * 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).
  31667. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31668. */
  31669. onPrePointerObservable: Observable<PointerInfoPre>;
  31670. /**
  31671. * Observable event triggered each time an input event is received from the rendering canvas
  31672. */
  31673. onPointerObservable: Observable<PointerInfo>;
  31674. /**
  31675. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31676. */
  31677. readonly unTranslatedPointer: Vector2;
  31678. /**
  31679. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  31680. */
  31681. static DragMovementThreshold: number;
  31682. /**
  31683. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  31684. */
  31685. static LongPressDelay: number;
  31686. /**
  31687. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  31688. */
  31689. static DoubleClickDelay: number;
  31690. /** If you need to check double click without raising a single click at first click, enable this flag */
  31691. static ExclusiveDoubleClickMode: boolean;
  31692. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  31693. /**
  31694. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31695. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31696. */
  31697. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31698. /**
  31699. * Observable event triggered each time an keyboard event is received from the hosting window
  31700. */
  31701. onKeyboardObservable: Observable<KeyboardInfo>;
  31702. private _useRightHandedSystem;
  31703. /**
  31704. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31705. */
  31706. useRightHandedSystem: boolean;
  31707. private _timeAccumulator;
  31708. private _currentStepId;
  31709. private _currentInternalStep;
  31710. /**
  31711. * Sets the step Id used by deterministic lock step
  31712. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31713. * @param newStepId defines the step Id
  31714. */
  31715. setStepId(newStepId: number): void;
  31716. /**
  31717. * Gets the step Id used by deterministic lock step
  31718. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31719. * @returns the step Id
  31720. */
  31721. getStepId(): number;
  31722. /**
  31723. * Gets the internal step used by deterministic lock step
  31724. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31725. * @returns the internal step
  31726. */
  31727. getInternalStep(): number;
  31728. private _fogEnabled;
  31729. /**
  31730. * Gets or sets a boolean indicating if fog is enabled on this scene
  31731. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31732. * (Default is true)
  31733. */
  31734. fogEnabled: boolean;
  31735. private _fogMode;
  31736. /**
  31737. * Gets or sets the fog mode to use
  31738. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31739. * | mode | value |
  31740. * | --- | --- |
  31741. * | FOGMODE_NONE | 0 |
  31742. * | FOGMODE_EXP | 1 |
  31743. * | FOGMODE_EXP2 | 2 |
  31744. * | FOGMODE_LINEAR | 3 |
  31745. */
  31746. fogMode: number;
  31747. /**
  31748. * Gets or sets the fog color to use
  31749. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31750. * (Default is Color3(0.2, 0.2, 0.3))
  31751. */
  31752. fogColor: Color3;
  31753. /**
  31754. * Gets or sets the fog density to use
  31755. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31756. * (Default is 0.1)
  31757. */
  31758. fogDensity: number;
  31759. /**
  31760. * Gets or sets the fog start distance to use
  31761. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31762. * (Default is 0)
  31763. */
  31764. fogStart: number;
  31765. /**
  31766. * Gets or sets the fog end distance to use
  31767. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31768. * (Default is 1000)
  31769. */
  31770. fogEnd: number;
  31771. private _shadowsEnabled;
  31772. /**
  31773. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31774. */
  31775. shadowsEnabled: boolean;
  31776. private _lightsEnabled;
  31777. /**
  31778. * Gets or sets a boolean indicating if lights are enabled on this scene
  31779. */
  31780. lightsEnabled: boolean;
  31781. /** All of the active cameras added to this scene. */
  31782. activeCameras: Camera[];
  31783. /** @hidden */ activeCamera: Nullable<Camera>;
  31784. /** Gets or sets the current active camera */
  31785. activeCamera: Nullable<Camera>;
  31786. private _defaultMaterial;
  31787. /** The default material used on meshes when no material is affected */
  31788. /** The default material used on meshes when no material is affected */
  31789. defaultMaterial: Material;
  31790. private _texturesEnabled;
  31791. /**
  31792. * Gets or sets a boolean indicating if textures are enabled on this scene
  31793. */
  31794. texturesEnabled: boolean;
  31795. /**
  31796. * Gets or sets a boolean indicating if particles are enabled on this scene
  31797. */
  31798. particlesEnabled: boolean;
  31799. /**
  31800. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31801. */
  31802. spritesEnabled: boolean;
  31803. private _skeletonsEnabled;
  31804. /**
  31805. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31806. */
  31807. skeletonsEnabled: boolean;
  31808. /**
  31809. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31810. */
  31811. lensFlaresEnabled: boolean;
  31812. /**
  31813. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31814. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31815. */
  31816. collisionsEnabled: boolean;
  31817. private _collisionCoordinator;
  31818. /** @hidden */
  31819. readonly collisionCoordinator: ICollisionCoordinator;
  31820. /**
  31821. * Defines the gravity applied to this scene (used only for collisions)
  31822. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31823. */
  31824. gravity: Vector3;
  31825. /**
  31826. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31827. */
  31828. postProcessesEnabled: boolean;
  31829. /**
  31830. * The list of postprocesses added to the scene
  31831. */
  31832. postProcesses: PostProcess[];
  31833. /**
  31834. * Gets the current postprocess manager
  31835. */
  31836. postProcessManager: PostProcessManager;
  31837. /**
  31838. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31839. */
  31840. renderTargetsEnabled: boolean;
  31841. /**
  31842. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31843. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31844. */
  31845. dumpNextRenderTargets: boolean;
  31846. /**
  31847. * The list of user defined render targets added to the scene
  31848. */
  31849. customRenderTargets: RenderTargetTexture[];
  31850. /**
  31851. * Defines if texture loading must be delayed
  31852. * If true, textures will only be loaded when they need to be rendered
  31853. */
  31854. useDelayedTextureLoading: boolean;
  31855. /**
  31856. * Gets the list of meshes imported to the scene through SceneLoader
  31857. */
  31858. importedMeshesFiles: String[];
  31859. /**
  31860. * Gets or sets a boolean indicating if probes are enabled on this scene
  31861. */
  31862. probesEnabled: boolean;
  31863. /**
  31864. * Gets or sets the current offline provider to use to store scene data
  31865. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31866. */
  31867. offlineProvider: IOfflineProvider;
  31868. /**
  31869. * Gets or sets the action manager associated with the scene
  31870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31871. */
  31872. actionManager: AbstractActionManager;
  31873. private _meshesForIntersections;
  31874. /**
  31875. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31876. */
  31877. proceduralTexturesEnabled: boolean;
  31878. private _engine;
  31879. private _totalVertices;
  31880. /** @hidden */ activeIndices: PerfCounter;
  31881. /** @hidden */ activeParticles: PerfCounter;
  31882. /** @hidden */ activeBones: PerfCounter;
  31883. private _animationRatio;
  31884. /** @hidden */ animationTimeLast: number;
  31885. /** @hidden */ animationTime: number;
  31886. /**
  31887. * Gets or sets a general scale for animation speed
  31888. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31889. */
  31890. animationTimeScale: number;
  31891. /** @hidden */ cachedMaterial: Nullable<Material>;
  31892. /** @hidden */ cachedEffect: Nullable<Effect>;
  31893. /** @hidden */ cachedVisibility: Nullable<number>;
  31894. private _renderId;
  31895. private _frameId;
  31896. private _executeWhenReadyTimeoutId;
  31897. private _intermediateRendering;
  31898. private _viewUpdateFlag;
  31899. private _projectionUpdateFlag;
  31900. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  31901. private _activeRequests;
  31902. /** @hidden */ pendingData: any[];
  31903. private _isDisposed;
  31904. /**
  31905. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31906. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31907. */
  31908. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31909. private _activeMeshes;
  31910. private _processedMaterials;
  31911. private _renderTargets;
  31912. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  31913. private _activeSkeletons;
  31914. private _softwareSkinnedMeshes;
  31915. private _renderingManager;
  31916. /** @hidden */ activeAnimatables: Animatable[];
  31917. private _transformMatrix;
  31918. private _sceneUbo;
  31919. /** @hidden */ viewMatrix: Matrix;
  31920. private _projectionMatrix;
  31921. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  31922. /** @hidden */ frustumPlanes: Plane[];
  31923. /**
  31924. * Gets the list of frustum planes (built from the active camera)
  31925. */
  31926. readonly frustumPlanes: Plane[];
  31927. /**
  31928. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31929. * This is useful if there are more lights that the maximum simulteanous authorized
  31930. */
  31931. requireLightSorting: boolean;
  31932. /** @hidden */
  31933. readonly useMaterialMeshMap: boolean;
  31934. /** @hidden */
  31935. readonly useClonedMeshhMap: boolean;
  31936. private _externalData;
  31937. private _uid;
  31938. /**
  31939. * @hidden
  31940. * Backing store of defined scene components.
  31941. */ components: ISceneComponent[];
  31942. /**
  31943. * @hidden
  31944. * Backing store of defined scene components.
  31945. */ serializableComponents: ISceneSerializableComponent[];
  31946. /**
  31947. * List of components to register on the next registration step.
  31948. */
  31949. private _transientComponents;
  31950. /**
  31951. * Registers the transient components if needed.
  31952. */
  31953. private _registerTransientComponents;
  31954. /**
  31955. * @hidden
  31956. * Add a component to the scene.
  31957. * Note that the ccomponent could be registered on th next frame if this is called after
  31958. * the register component stage.
  31959. * @param component Defines the component to add to the scene
  31960. */ addComponent(component: ISceneComponent): void;
  31961. /**
  31962. * @hidden
  31963. * Gets a component from the scene.
  31964. * @param name defines the name of the component to retrieve
  31965. * @returns the component or null if not present
  31966. */ getComponent(name: string): Nullable<ISceneComponent>;
  31967. /**
  31968. * @hidden
  31969. * Defines the actions happening before camera updates.
  31970. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31971. /**
  31972. * @hidden
  31973. * Defines the actions happening before clear the canvas.
  31974. */ beforeClearStage: Stage<SimpleStageAction>;
  31975. /**
  31976. * @hidden
  31977. * Defines the actions when collecting render targets for the frame.
  31978. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31979. /**
  31980. * @hidden
  31981. * Defines the actions happening for one camera in the frame.
  31982. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31983. /**
  31984. * @hidden
  31985. * Defines the actions happening during the per mesh ready checks.
  31986. */ isReadyForMeshStage: Stage<MeshStageAction>;
  31987. /**
  31988. * @hidden
  31989. * Defines the actions happening before evaluate active mesh checks.
  31990. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31991. /**
  31992. * @hidden
  31993. * Defines the actions happening during the evaluate sub mesh checks.
  31994. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31995. /**
  31996. * @hidden
  31997. * Defines the actions happening during the active mesh stage.
  31998. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  31999. /**
  32000. * @hidden
  32001. * Defines the actions happening during the per camera render target step.
  32002. */ cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32003. /**
  32004. * @hidden
  32005. * Defines the actions happening just before the active camera is drawing.
  32006. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  32007. /**
  32008. * @hidden
  32009. * Defines the actions happening just before a render target is drawing.
  32010. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32011. /**
  32012. * @hidden
  32013. * Defines the actions happening just before a rendering group is drawing.
  32014. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32015. /**
  32016. * @hidden
  32017. * Defines the actions happening just before a mesh is drawing.
  32018. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32019. /**
  32020. * @hidden
  32021. * Defines the actions happening just after a mesh has been drawn.
  32022. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32023. /**
  32024. * @hidden
  32025. * Defines the actions happening just after a rendering group has been drawn.
  32026. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32027. /**
  32028. * @hidden
  32029. * Defines the actions happening just after the active camera has been drawn.
  32030. */ afterCameraDrawStage: Stage<CameraStageAction>;
  32031. /**
  32032. * @hidden
  32033. * Defines the actions happening just after a render target has been drawn.
  32034. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32035. /**
  32036. * @hidden
  32037. * Defines the actions happening just after rendering all cameras and computing intersections.
  32038. */ afterRenderStage: Stage<SimpleStageAction>;
  32039. /**
  32040. * @hidden
  32041. * Defines the actions happening when a pointer move event happens.
  32042. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  32043. /**
  32044. * @hidden
  32045. * Defines the actions happening when a pointer down event happens.
  32046. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  32047. /**
  32048. * @hidden
  32049. * Defines the actions happening when a pointer up event happens.
  32050. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  32051. /**
  32052. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32053. */
  32054. private geometriesByUniqueId;
  32055. /**
  32056. * Creates a new Scene
  32057. * @param engine defines the engine to use to render this scene
  32058. * @param options defines the scene options
  32059. */
  32060. constructor(engine: Engine, options?: SceneOptions);
  32061. /**
  32062. * Gets a string idenfifying the name of the class
  32063. * @returns "Scene" string
  32064. */
  32065. getClassName(): string;
  32066. private _defaultMeshCandidates;
  32067. /**
  32068. * @hidden
  32069. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32070. private _defaultSubMeshCandidates;
  32071. /**
  32072. * @hidden
  32073. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32074. /**
  32075. * Sets the default candidate providers for the scene.
  32076. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32077. * and getCollidingSubMeshCandidates to their default function
  32078. */
  32079. setDefaultCandidateProviders(): void;
  32080. /**
  32081. * Gets the mesh that is currently under the pointer
  32082. */
  32083. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32084. /**
  32085. * Gets or sets the current on-screen X position of the pointer
  32086. */
  32087. pointerX: number;
  32088. /**
  32089. * Gets or sets the current on-screen Y position of the pointer
  32090. */
  32091. pointerY: number;
  32092. /**
  32093. * Gets the cached material (ie. the latest rendered one)
  32094. * @returns the cached material
  32095. */
  32096. getCachedMaterial(): Nullable<Material>;
  32097. /**
  32098. * Gets the cached effect (ie. the latest rendered one)
  32099. * @returns the cached effect
  32100. */
  32101. getCachedEffect(): Nullable<Effect>;
  32102. /**
  32103. * Gets the cached visibility state (ie. the latest rendered one)
  32104. * @returns the cached visibility state
  32105. */
  32106. getCachedVisibility(): Nullable<number>;
  32107. /**
  32108. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32109. * @param material defines the current material
  32110. * @param effect defines the current effect
  32111. * @param visibility defines the current visibility state
  32112. * @returns true if one parameter is not cached
  32113. */
  32114. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32115. /**
  32116. * Gets the engine associated with the scene
  32117. * @returns an Engine
  32118. */
  32119. getEngine(): Engine;
  32120. /**
  32121. * Gets the total number of vertices rendered per frame
  32122. * @returns the total number of vertices rendered per frame
  32123. */
  32124. getTotalVertices(): number;
  32125. /**
  32126. * Gets the performance counter for total vertices
  32127. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32128. */
  32129. readonly totalVerticesPerfCounter: PerfCounter;
  32130. /**
  32131. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32132. * @returns the total number of active indices rendered per frame
  32133. */
  32134. getActiveIndices(): number;
  32135. /**
  32136. * Gets the performance counter for active indices
  32137. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32138. */
  32139. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32140. /**
  32141. * Gets the total number of active particles rendered per frame
  32142. * @returns the total number of active particles rendered per frame
  32143. */
  32144. getActiveParticles(): number;
  32145. /**
  32146. * Gets the performance counter for active particles
  32147. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32148. */
  32149. readonly activeParticlesPerfCounter: PerfCounter;
  32150. /**
  32151. * Gets the total number of active bones rendered per frame
  32152. * @returns the total number of active bones rendered per frame
  32153. */
  32154. getActiveBones(): number;
  32155. /**
  32156. * Gets the performance counter for active bones
  32157. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32158. */
  32159. readonly activeBonesPerfCounter: PerfCounter;
  32160. /**
  32161. * Gets the array of active meshes
  32162. * @returns an array of AbstractMesh
  32163. */
  32164. getActiveMeshes(): SmartArray<AbstractMesh>;
  32165. /**
  32166. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32167. * @returns a number
  32168. */
  32169. getAnimationRatio(): number;
  32170. /**
  32171. * Gets an unique Id for the current render phase
  32172. * @returns a number
  32173. */
  32174. getRenderId(): number;
  32175. /**
  32176. * Gets an unique Id for the current frame
  32177. * @returns a number
  32178. */
  32179. getFrameId(): number;
  32180. /** Call this function if you want to manually increment the render Id*/
  32181. incrementRenderId(): void;
  32182. private _createUbo;
  32183. /**
  32184. * Use this method to simulate a pointer move on a mesh
  32185. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32186. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32187. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32188. * @returns the current scene
  32189. */
  32190. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32191. /**
  32192. * Use this method to simulate a pointer down on a mesh
  32193. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32194. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32195. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32196. * @returns the current scene
  32197. */
  32198. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32199. /**
  32200. * Use this method to simulate a pointer up on a mesh
  32201. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32202. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32203. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32204. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32205. * @returns the current scene
  32206. */
  32207. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32208. /**
  32209. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32210. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32211. * @returns true if the pointer was captured
  32212. */
  32213. isPointerCaptured(pointerId?: number): boolean;
  32214. /**
  32215. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32216. * @param attachUp defines if you want to attach events to pointerup
  32217. * @param attachDown defines if you want to attach events to pointerdown
  32218. * @param attachMove defines if you want to attach events to pointermove
  32219. */
  32220. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32221. /** Detaches all event handlers*/
  32222. detachControl(): void;
  32223. /**
  32224. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32225. * Delay loaded resources are not taking in account
  32226. * @return true if all required resources are ready
  32227. */
  32228. isReady(): boolean;
  32229. /** Resets all cached information relative to material (including effect and visibility) */
  32230. resetCachedMaterial(): void;
  32231. /**
  32232. * Registers a function to be called before every frame render
  32233. * @param func defines the function to register
  32234. */
  32235. registerBeforeRender(func: () => void): void;
  32236. /**
  32237. * Unregisters a function called before every frame render
  32238. * @param func defines the function to unregister
  32239. */
  32240. unregisterBeforeRender(func: () => void): void;
  32241. /**
  32242. * Registers a function to be called after every frame render
  32243. * @param func defines the function to register
  32244. */
  32245. registerAfterRender(func: () => void): void;
  32246. /**
  32247. * Unregisters a function called after every frame render
  32248. * @param func defines the function to unregister
  32249. */
  32250. unregisterAfterRender(func: () => void): void;
  32251. private _executeOnceBeforeRender;
  32252. /**
  32253. * The provided function will run before render once and will be disposed afterwards.
  32254. * A timeout delay can be provided so that the function will be executed in N ms.
  32255. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32256. * @param func The function to be executed.
  32257. * @param timeout optional delay in ms
  32258. */
  32259. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32260. /** @hidden */ addPendingData(data: any): void;
  32261. /** @hidden */ removePendingData(data: any): void;
  32262. /**
  32263. * Returns the number of items waiting to be loaded
  32264. * @returns the number of items waiting to be loaded
  32265. */
  32266. getWaitingItemsCount(): number;
  32267. /**
  32268. * Returns a boolean indicating if the scene is still loading data
  32269. */
  32270. readonly isLoading: boolean;
  32271. /**
  32272. * Registers a function to be executed when the scene is ready
  32273. * @param {Function} func - the function to be executed
  32274. */
  32275. executeWhenReady(func: () => void): void;
  32276. /**
  32277. * Returns a promise that resolves when the scene is ready
  32278. * @returns A promise that resolves when the scene is ready
  32279. */
  32280. whenReadyAsync(): Promise<void>;
  32281. /** @hidden */ checkIsReady(): void;
  32282. /**
  32283. * Gets all animatable attached to the scene
  32284. */
  32285. readonly animatables: Animatable[];
  32286. /**
  32287. * Resets the last animation time frame.
  32288. * Useful to override when animations start running when loading a scene for the first time.
  32289. */
  32290. resetLastAnimationTimeFrame(): void;
  32291. /**
  32292. * Gets the current view matrix
  32293. * @returns a Matrix
  32294. */
  32295. getViewMatrix(): Matrix;
  32296. /**
  32297. * Gets the current projection matrix
  32298. * @returns a Matrix
  32299. */
  32300. getProjectionMatrix(): Matrix;
  32301. /**
  32302. * Gets the current transform matrix
  32303. * @returns a Matrix made of View * Projection
  32304. */
  32305. getTransformMatrix(): Matrix;
  32306. /**
  32307. * Sets the current transform matrix
  32308. * @param viewL defines the View matrix to use
  32309. * @param projectionL defines the Projection matrix to use
  32310. * @param viewR defines the right View matrix to use (if provided)
  32311. * @param projectionR defines the right Projection matrix to use (if provided)
  32312. */
  32313. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32314. /**
  32315. * Gets the uniform buffer used to store scene data
  32316. * @returns a UniformBuffer
  32317. */
  32318. getSceneUniformBuffer(): UniformBuffer;
  32319. /**
  32320. * Gets an unique (relatively to the current scene) Id
  32321. * @returns an unique number for the scene
  32322. */
  32323. getUniqueId(): number;
  32324. /**
  32325. * Add a mesh to the list of scene's meshes
  32326. * @param newMesh defines the mesh to add
  32327. * @param recursive if all child meshes should also be added to the scene
  32328. */
  32329. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32330. /**
  32331. * Remove a mesh for the list of scene's meshes
  32332. * @param toRemove defines the mesh to remove
  32333. * @param recursive if all child meshes should also be removed from the scene
  32334. * @returns the index where the mesh was in the mesh list
  32335. */
  32336. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32337. /**
  32338. * Add a transform node to the list of scene's transform nodes
  32339. * @param newTransformNode defines the transform node to add
  32340. */
  32341. addTransformNode(newTransformNode: TransformNode): void;
  32342. /**
  32343. * Remove a transform node for the list of scene's transform nodes
  32344. * @param toRemove defines the transform node to remove
  32345. * @returns the index where the transform node was in the transform node list
  32346. */
  32347. removeTransformNode(toRemove: TransformNode): number;
  32348. /**
  32349. * Remove a skeleton for the list of scene's skeletons
  32350. * @param toRemove defines the skeleton to remove
  32351. * @returns the index where the skeleton was in the skeleton list
  32352. */
  32353. removeSkeleton(toRemove: Skeleton): number;
  32354. /**
  32355. * Remove a morph target for the list of scene's morph targets
  32356. * @param toRemove defines the morph target to remove
  32357. * @returns the index where the morph target was in the morph target list
  32358. */
  32359. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32360. /**
  32361. * Remove a light for the list of scene's lights
  32362. * @param toRemove defines the light to remove
  32363. * @returns the index where the light was in the light list
  32364. */
  32365. removeLight(toRemove: Light): number;
  32366. /**
  32367. * Remove a camera for the list of scene's cameras
  32368. * @param toRemove defines the camera to remove
  32369. * @returns the index where the camera was in the camera list
  32370. */
  32371. removeCamera(toRemove: Camera): number;
  32372. /**
  32373. * Remove a particle system for the list of scene's particle systems
  32374. * @param toRemove defines the particle system to remove
  32375. * @returns the index where the particle system was in the particle system list
  32376. */
  32377. removeParticleSystem(toRemove: IParticleSystem): number;
  32378. /**
  32379. * Remove a animation for the list of scene's animations
  32380. * @param toRemove defines the animation to remove
  32381. * @returns the index where the animation was in the animation list
  32382. */
  32383. removeAnimation(toRemove: Animation): number;
  32384. /**
  32385. * Removes the given animation group from this scene.
  32386. * @param toRemove The animation group to remove
  32387. * @returns The index of the removed animation group
  32388. */
  32389. removeAnimationGroup(toRemove: AnimationGroup): number;
  32390. /**
  32391. * Removes the given multi-material from this scene.
  32392. * @param toRemove The multi-material to remove
  32393. * @returns The index of the removed multi-material
  32394. */
  32395. removeMultiMaterial(toRemove: MultiMaterial): number;
  32396. /**
  32397. * Removes the given material from this scene.
  32398. * @param toRemove The material to remove
  32399. * @returns The index of the removed material
  32400. */
  32401. removeMaterial(toRemove: Material): number;
  32402. /**
  32403. * Removes the given action manager from this scene.
  32404. * @param toRemove The action manager to remove
  32405. * @returns The index of the removed action manager
  32406. */
  32407. removeActionManager(toRemove: AbstractActionManager): number;
  32408. /**
  32409. * Removes the given texture from this scene.
  32410. * @param toRemove The texture to remove
  32411. * @returns The index of the removed texture
  32412. */
  32413. removeTexture(toRemove: BaseTexture): number;
  32414. /**
  32415. * Adds the given light to this scene
  32416. * @param newLight The light to add
  32417. */
  32418. addLight(newLight: Light): void;
  32419. /**
  32420. * Sorts the list list based on light priorities
  32421. */
  32422. sortLightsByPriority(): void;
  32423. /**
  32424. * Adds the given camera to this scene
  32425. * @param newCamera The camera to add
  32426. */
  32427. addCamera(newCamera: Camera): void;
  32428. /**
  32429. * Adds the given skeleton to this scene
  32430. * @param newSkeleton The skeleton to add
  32431. */
  32432. addSkeleton(newSkeleton: Skeleton): void;
  32433. /**
  32434. * Adds the given particle system to this scene
  32435. * @param newParticleSystem The particle system to add
  32436. */
  32437. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32438. /**
  32439. * Adds the given animation to this scene
  32440. * @param newAnimation The animation to add
  32441. */
  32442. addAnimation(newAnimation: Animation): void;
  32443. /**
  32444. * Adds the given animation group to this scene.
  32445. * @param newAnimationGroup The animation group to add
  32446. */
  32447. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32448. /**
  32449. * Adds the given multi-material to this scene
  32450. * @param newMultiMaterial The multi-material to add
  32451. */
  32452. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32453. /**
  32454. * Adds the given material to this scene
  32455. * @param newMaterial The material to add
  32456. */
  32457. addMaterial(newMaterial: Material): void;
  32458. /**
  32459. * Adds the given morph target to this scene
  32460. * @param newMorphTargetManager The morph target to add
  32461. */
  32462. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32463. /**
  32464. * Adds the given geometry to this scene
  32465. * @param newGeometry The geometry to add
  32466. */
  32467. addGeometry(newGeometry: Geometry): void;
  32468. /**
  32469. * Adds the given action manager to this scene
  32470. * @param newActionManager The action manager to add
  32471. */
  32472. addActionManager(newActionManager: AbstractActionManager): void;
  32473. /**
  32474. * Adds the given texture to this scene.
  32475. * @param newTexture The texture to add
  32476. */
  32477. addTexture(newTexture: BaseTexture): void;
  32478. /**
  32479. * Switch active camera
  32480. * @param newCamera defines the new active camera
  32481. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32482. */
  32483. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32484. /**
  32485. * sets the active camera of the scene using its ID
  32486. * @param id defines the camera's ID
  32487. * @return the new active camera or null if none found.
  32488. */
  32489. setActiveCameraByID(id: string): Nullable<Camera>;
  32490. /**
  32491. * sets the active camera of the scene using its name
  32492. * @param name defines the camera's name
  32493. * @returns the new active camera or null if none found.
  32494. */
  32495. setActiveCameraByName(name: string): Nullable<Camera>;
  32496. /**
  32497. * get an animation group using its name
  32498. * @param name defines the material's name
  32499. * @return the animation group or null if none found.
  32500. */
  32501. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32502. /**
  32503. * Get a material using its unique id
  32504. * @param uniqueId defines the material's unique id
  32505. * @return the material or null if none found.
  32506. */
  32507. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32508. /**
  32509. * get a material using its id
  32510. * @param id defines the material's ID
  32511. * @return the material or null if none found.
  32512. */
  32513. getMaterialByID(id: string): Nullable<Material>;
  32514. /**
  32515. * Gets a material using its name
  32516. * @param name defines the material's name
  32517. * @return the material or null if none found.
  32518. */
  32519. getMaterialByName(name: string): Nullable<Material>;
  32520. /**
  32521. * Gets a camera using its id
  32522. * @param id defines the id to look for
  32523. * @returns the camera or null if not found
  32524. */
  32525. getCameraByID(id: string): Nullable<Camera>;
  32526. /**
  32527. * Gets a camera using its unique id
  32528. * @param uniqueId defines the unique id to look for
  32529. * @returns the camera or null if not found
  32530. */
  32531. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32532. /**
  32533. * Gets a camera using its name
  32534. * @param name defines the camera's name
  32535. * @return the camera or null if none found.
  32536. */
  32537. getCameraByName(name: string): Nullable<Camera>;
  32538. /**
  32539. * Gets a bone using its id
  32540. * @param id defines the bone's id
  32541. * @return the bone or null if not found
  32542. */
  32543. getBoneByID(id: string): Nullable<Bone>;
  32544. /**
  32545. * Gets a bone using its id
  32546. * @param name defines the bone's name
  32547. * @return the bone or null if not found
  32548. */
  32549. getBoneByName(name: string): Nullable<Bone>;
  32550. /**
  32551. * Gets a light node using its name
  32552. * @param name defines the the light's name
  32553. * @return the light or null if none found.
  32554. */
  32555. getLightByName(name: string): Nullable<Light>;
  32556. /**
  32557. * Gets a light node using its id
  32558. * @param id defines the light's id
  32559. * @return the light or null if none found.
  32560. */
  32561. getLightByID(id: string): Nullable<Light>;
  32562. /**
  32563. * Gets a light node using its scene-generated unique ID
  32564. * @param uniqueId defines the light's unique id
  32565. * @return the light or null if none found.
  32566. */
  32567. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32568. /**
  32569. * Gets a particle system by id
  32570. * @param id defines the particle system id
  32571. * @return the corresponding system or null if none found
  32572. */
  32573. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32574. /**
  32575. * Gets a geometry using its ID
  32576. * @param id defines the geometry's id
  32577. * @return the geometry or null if none found.
  32578. */
  32579. getGeometryByID(id: string): Nullable<Geometry>;
  32580. private _getGeometryByUniqueID;
  32581. /**
  32582. * Add a new geometry to this scene
  32583. * @param geometry defines the geometry to be added to the scene.
  32584. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32585. * @return a boolean defining if the geometry was added or not
  32586. */
  32587. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32588. /**
  32589. * Removes an existing geometry
  32590. * @param geometry defines the geometry to be removed from the scene
  32591. * @return a boolean defining if the geometry was removed or not
  32592. */
  32593. removeGeometry(geometry: Geometry): boolean;
  32594. /**
  32595. * Gets the list of geometries attached to the scene
  32596. * @returns an array of Geometry
  32597. */
  32598. getGeometries(): Geometry[];
  32599. /**
  32600. * Gets the first added mesh found of a given ID
  32601. * @param id defines the id to search for
  32602. * @return the mesh found or null if not found at all
  32603. */
  32604. getMeshByID(id: string): Nullable<AbstractMesh>;
  32605. /**
  32606. * Gets a list of meshes using their id
  32607. * @param id defines the id to search for
  32608. * @returns a list of meshes
  32609. */
  32610. getMeshesByID(id: string): Array<AbstractMesh>;
  32611. /**
  32612. * Gets the first added transform node found of a given ID
  32613. * @param id defines the id to search for
  32614. * @return the found transform node or null if not found at all.
  32615. */
  32616. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32617. /**
  32618. * Gets a transform node with its auto-generated unique id
  32619. * @param uniqueId efines the unique id to search for
  32620. * @return the found transform node or null if not found at all.
  32621. */
  32622. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32623. /**
  32624. * Gets a list of transform nodes using their id
  32625. * @param id defines the id to search for
  32626. * @returns a list of transform nodes
  32627. */
  32628. getTransformNodesByID(id: string): Array<TransformNode>;
  32629. /**
  32630. * Gets a mesh with its auto-generated unique id
  32631. * @param uniqueId defines the unique id to search for
  32632. * @return the found mesh or null if not found at all.
  32633. */
  32634. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32635. /**
  32636. * Gets a the last added mesh using a given id
  32637. * @param id defines the id to search for
  32638. * @return the found mesh or null if not found at all.
  32639. */
  32640. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32641. /**
  32642. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32643. * @param id defines the id to search for
  32644. * @return the found node or null if not found at all
  32645. */
  32646. getLastEntryByID(id: string): Nullable<Node>;
  32647. /**
  32648. * Gets a node (Mesh, Camera, Light) using a given id
  32649. * @param id defines the id to search for
  32650. * @return the found node or null if not found at all
  32651. */
  32652. getNodeByID(id: string): Nullable<Node>;
  32653. /**
  32654. * Gets a node (Mesh, Camera, Light) using a given name
  32655. * @param name defines the name to search for
  32656. * @return the found node or null if not found at all.
  32657. */
  32658. getNodeByName(name: string): Nullable<Node>;
  32659. /**
  32660. * Gets a mesh using a given name
  32661. * @param name defines the name to search for
  32662. * @return the found mesh or null if not found at all.
  32663. */
  32664. getMeshByName(name: string): Nullable<AbstractMesh>;
  32665. /**
  32666. * Gets a transform node using a given name
  32667. * @param name defines the name to search for
  32668. * @return the found transform node or null if not found at all.
  32669. */
  32670. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32671. /**
  32672. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32673. * @param id defines the id to search for
  32674. * @return the found skeleton or null if not found at all.
  32675. */
  32676. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32677. /**
  32678. * Gets a skeleton using a given auto generated unique id
  32679. * @param uniqueId defines the unique id to search for
  32680. * @return the found skeleton or null if not found at all.
  32681. */
  32682. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32683. /**
  32684. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32685. * @param id defines the id to search for
  32686. * @return the found skeleton or null if not found at all.
  32687. */
  32688. getSkeletonById(id: string): Nullable<Skeleton>;
  32689. /**
  32690. * Gets a skeleton using a given name
  32691. * @param name defines the name to search for
  32692. * @return the found skeleton or null if not found at all.
  32693. */
  32694. getSkeletonByName(name: string): Nullable<Skeleton>;
  32695. /**
  32696. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32697. * @param id defines the id to search for
  32698. * @return the found morph target manager or null if not found at all.
  32699. */
  32700. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32701. /**
  32702. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32703. * @param id defines the id to search for
  32704. * @return the found morph target or null if not found at all.
  32705. */
  32706. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32707. /**
  32708. * Gets a boolean indicating if the given mesh is active
  32709. * @param mesh defines the mesh to look for
  32710. * @returns true if the mesh is in the active list
  32711. */
  32712. isActiveMesh(mesh: AbstractMesh): boolean;
  32713. /**
  32714. * Return a unique id as a string which can serve as an identifier for the scene
  32715. */
  32716. readonly uid: string;
  32717. /**
  32718. * Add an externaly attached data from its key.
  32719. * This method call will fail and return false, if such key already exists.
  32720. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32721. * @param key the unique key that identifies the data
  32722. * @param data the data object to associate to the key for this Engine instance
  32723. * @return true if no such key were already present and the data was added successfully, false otherwise
  32724. */
  32725. addExternalData<T>(key: string, data: T): boolean;
  32726. /**
  32727. * Get an externaly attached data from its key
  32728. * @param key the unique key that identifies the data
  32729. * @return the associated data, if present (can be null), or undefined if not present
  32730. */
  32731. getExternalData<T>(key: string): Nullable<T>;
  32732. /**
  32733. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32734. * @param key the unique key that identifies the data
  32735. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32736. * @return the associated data, can be null if the factory returned null.
  32737. */
  32738. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32739. /**
  32740. * Remove an externaly attached data from the Engine instance
  32741. * @param key the unique key that identifies the data
  32742. * @return true if the data was successfully removed, false if it doesn't exist
  32743. */
  32744. removeExternalData(key: string): boolean;
  32745. private _evaluateSubMesh;
  32746. /**
  32747. * Clear the processed materials smart array preventing retention point in material dispose.
  32748. */
  32749. freeProcessedMaterials(): void;
  32750. private _preventFreeActiveMeshesAndRenderingGroups;
  32751. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32752. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32753. * when disposing several meshes in a row or a hierarchy of meshes.
  32754. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32755. */
  32756. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32757. /**
  32758. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32759. */
  32760. freeActiveMeshes(): void;
  32761. /**
  32762. * Clear the info related to rendering groups preventing retention points during dispose.
  32763. */
  32764. freeRenderingGroups(): void;
  32765. /** @hidden */ isInIntermediateRendering(): boolean;
  32766. /**
  32767. * Lambda returning the list of potentially active meshes.
  32768. */
  32769. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32770. /**
  32771. * Lambda returning the list of potentially active sub meshes.
  32772. */
  32773. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32774. /**
  32775. * Lambda returning the list of potentially intersecting sub meshes.
  32776. */
  32777. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32778. /**
  32779. * Lambda returning the list of potentially colliding sub meshes.
  32780. */
  32781. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32782. private _activeMeshesFrozen;
  32783. /**
  32784. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32785. * @returns the current scene
  32786. */
  32787. freezeActiveMeshes(): Scene;
  32788. /**
  32789. * Use this function to restart evaluating active meshes on every frame
  32790. * @returns the current scene
  32791. */
  32792. unfreezeActiveMeshes(): Scene;
  32793. private _evaluateActiveMeshes;
  32794. private _activeMesh;
  32795. /**
  32796. * Update the transform matrix to update from the current active camera
  32797. * @param force defines a boolean used to force the update even if cache is up to date
  32798. */
  32799. updateTransformMatrix(force?: boolean): void;
  32800. private _bindFrameBuffer;
  32801. /** @hidden */ allowPostProcessClearColor: boolean;
  32802. /** @hidden */ renderForCamera(camera: Camera, rigParent?: Camera): void;
  32803. private _processSubCameras;
  32804. private _checkIntersections;
  32805. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  32806. /**
  32807. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32808. */
  32809. getDeterministicFrameTime: () => number;
  32810. /** @hidden */ animate(): void;
  32811. /** Execute all animations (for a frame) */
  32812. animate(): void;
  32813. /**
  32814. * Render the scene
  32815. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32816. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  32817. */
  32818. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  32819. /**
  32820. * Freeze all materials
  32821. * A frozen material will not be updatable but should be faster to render
  32822. */
  32823. freezeMaterials(): void;
  32824. /**
  32825. * Unfreeze all materials
  32826. * A frozen material will not be updatable but should be faster to render
  32827. */
  32828. unfreezeMaterials(): void;
  32829. /**
  32830. * Releases all held ressources
  32831. */
  32832. dispose(): void;
  32833. /**
  32834. * Gets if the scene is already disposed
  32835. */
  32836. readonly isDisposed: boolean;
  32837. /**
  32838. * Call this function to reduce memory footprint of the scene.
  32839. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32840. */
  32841. clearCachedVertexData(): void;
  32842. /**
  32843. * This function will remove the local cached buffer data from texture.
  32844. * It will save memory but will prevent the texture from being rebuilt
  32845. */
  32846. cleanCachedTextureBuffer(): void;
  32847. /**
  32848. * Get the world extend vectors with an optional filter
  32849. *
  32850. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32851. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32852. */
  32853. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32854. min: Vector3;
  32855. max: Vector3;
  32856. };
  32857. /**
  32858. * Creates a ray that can be used to pick in the scene
  32859. * @param x defines the x coordinate of the origin (on-screen)
  32860. * @param y defines the y coordinate of the origin (on-screen)
  32861. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32862. * @param camera defines the camera to use for the picking
  32863. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32864. * @returns a Ray
  32865. */
  32866. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32867. /**
  32868. * Creates a ray that can be used to pick in the scene
  32869. * @param x defines the x coordinate of the origin (on-screen)
  32870. * @param y defines the y coordinate of the origin (on-screen)
  32871. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32872. * @param result defines the ray where to store the picking ray
  32873. * @param camera defines the camera to use for the picking
  32874. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32875. * @returns the current scene
  32876. */
  32877. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32878. /**
  32879. * Creates a ray that can be used to pick in the scene
  32880. * @param x defines the x coordinate of the origin (on-screen)
  32881. * @param y defines the y coordinate of the origin (on-screen)
  32882. * @param camera defines the camera to use for the picking
  32883. * @returns a Ray
  32884. */
  32885. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32886. /**
  32887. * Creates a ray that can be used to pick in the scene
  32888. * @param x defines the x coordinate of the origin (on-screen)
  32889. * @param y defines the y coordinate of the origin (on-screen)
  32890. * @param result defines the ray where to store the picking ray
  32891. * @param camera defines the camera to use for the picking
  32892. * @returns the current scene
  32893. */
  32894. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32895. /** Launch a ray to try to pick a mesh in the scene
  32896. * @param x position on screen
  32897. * @param y position on screen
  32898. * @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
  32899. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32900. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32901. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32902. * @returns a PickingInfo
  32903. */
  32904. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  32905. /** Use the given ray to pick a mesh in the scene
  32906. * @param ray The ray to use to pick meshes
  32907. * @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
  32908. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32909. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32910. * @returns a PickingInfo
  32911. */
  32912. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  32913. /**
  32914. * Launch a ray to try to pick a mesh in the scene
  32915. * @param x X position on screen
  32916. * @param y Y position on screen
  32917. * @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
  32918. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32919. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32920. * @returns an array of PickingInfo
  32921. */
  32922. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32923. /**
  32924. * Launch a ray to try to pick a mesh in the scene
  32925. * @param ray Ray to use
  32926. * @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
  32927. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32928. * @returns an array of PickingInfo
  32929. */
  32930. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32931. /**
  32932. * Force the value of meshUnderPointer
  32933. * @param mesh defines the mesh to use
  32934. */
  32935. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32936. /**
  32937. * Gets the mesh under the pointer
  32938. * @returns a Mesh or null if no mesh is under the pointer
  32939. */
  32940. getPointerOverMesh(): Nullable<AbstractMesh>;
  32941. /** @hidden */ rebuildGeometries(): void;
  32942. /** @hidden */ rebuildTextures(): void;
  32943. private _getByTags;
  32944. /**
  32945. * Get a list of meshes by tags
  32946. * @param tagsQuery defines the tags query to use
  32947. * @param forEach defines a predicate used to filter results
  32948. * @returns an array of Mesh
  32949. */
  32950. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32951. /**
  32952. * Get a list of cameras by tags
  32953. * @param tagsQuery defines the tags query to use
  32954. * @param forEach defines a predicate used to filter results
  32955. * @returns an array of Camera
  32956. */
  32957. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32958. /**
  32959. * Get a list of lights by tags
  32960. * @param tagsQuery defines the tags query to use
  32961. * @param forEach defines a predicate used to filter results
  32962. * @returns an array of Light
  32963. */
  32964. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32965. /**
  32966. * Get a list of materials by tags
  32967. * @param tagsQuery defines the tags query to use
  32968. * @param forEach defines a predicate used to filter results
  32969. * @returns an array of Material
  32970. */
  32971. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32972. /**
  32973. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32974. * This allowed control for front to back rendering or reversly depending of the special needs.
  32975. *
  32976. * @param renderingGroupId The rendering group id corresponding to its index
  32977. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32978. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32979. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32980. */
  32981. 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;
  32982. /**
  32983. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32984. *
  32985. * @param renderingGroupId The rendering group id corresponding to its index
  32986. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32987. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32988. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32989. */
  32990. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32991. /**
  32992. * Gets the current auto clear configuration for one rendering group of the rendering
  32993. * manager.
  32994. * @param index the rendering group index to get the information for
  32995. * @returns The auto clear setup for the requested rendering group
  32996. */
  32997. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32998. private _blockMaterialDirtyMechanism;
  32999. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33000. blockMaterialDirtyMechanism: boolean;
  33001. /**
  33002. * Will flag all materials as dirty to trigger new shader compilation
  33003. * @param flag defines the flag used to specify which material part must be marked as dirty
  33004. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33005. */
  33006. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33007. /** @hidden */ loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33008. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33009. }
  33010. }
  33011. declare module BABYLON {
  33012. /**
  33013. * Set of assets to keep when moving a scene into an asset container.
  33014. */
  33015. export class KeepAssets extends AbstractScene {
  33016. }
  33017. /**
  33018. * Container with a set of assets that can be added or removed from a scene.
  33019. */
  33020. export class AssetContainer extends AbstractScene {
  33021. /**
  33022. * The scene the AssetContainer belongs to.
  33023. */
  33024. scene: Scene;
  33025. /**
  33026. * Instantiates an AssetContainer.
  33027. * @param scene The scene the AssetContainer belongs to.
  33028. */
  33029. constructor(scene: Scene);
  33030. /**
  33031. * Adds all the assets from the container to the scene.
  33032. */
  33033. addAllToScene(): void;
  33034. /**
  33035. * Removes all the assets in the container from the scene
  33036. */
  33037. removeAllFromScene(): void;
  33038. /**
  33039. * Disposes all the assets in the container
  33040. */
  33041. dispose(): void;
  33042. private _moveAssets;
  33043. /**
  33044. * Removes all the assets contained in the scene and adds them to the container.
  33045. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33046. */
  33047. moveAllFromScene(keepAssets?: KeepAssets): void;
  33048. /**
  33049. * 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.
  33050. * @returns the root mesh
  33051. */
  33052. createRootMesh(): Mesh;
  33053. }
  33054. }
  33055. declare module BABYLON {
  33056. /**
  33057. * Defines how the parser contract is defined.
  33058. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33059. */
  33060. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33061. /**
  33062. * Defines how the individual parser contract is defined.
  33063. * These parser can parse an individual asset
  33064. */
  33065. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33066. /**
  33067. * Base class of the scene acting as a container for the different elements composing a scene.
  33068. * This class is dynamically extended by the different components of the scene increasing
  33069. * flexibility and reducing coupling
  33070. */
  33071. export abstract class AbstractScene {
  33072. /**
  33073. * Stores the list of available parsers in the application.
  33074. */
  33075. private static _BabylonFileParsers;
  33076. /**
  33077. * Stores the list of available individual parsers in the application.
  33078. */
  33079. private static _IndividualBabylonFileParsers;
  33080. /**
  33081. * Adds a parser in the list of available ones
  33082. * @param name Defines the name of the parser
  33083. * @param parser Defines the parser to add
  33084. */
  33085. static AddParser(name: string, parser: BabylonFileParser): void;
  33086. /**
  33087. * Gets a general parser from the list of avaialble ones
  33088. * @param name Defines the name of the parser
  33089. * @returns the requested parser or null
  33090. */
  33091. static GetParser(name: string): Nullable<BabylonFileParser>;
  33092. /**
  33093. * Adds n individual parser in the list of available ones
  33094. * @param name Defines the name of the parser
  33095. * @param parser Defines the parser to add
  33096. */
  33097. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33098. /**
  33099. * Gets an individual parser from the list of avaialble ones
  33100. * @param name Defines the name of the parser
  33101. * @returns the requested parser or null
  33102. */
  33103. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33104. /**
  33105. * Parser json data and populate both a scene and its associated container object
  33106. * @param jsonData Defines the data to parse
  33107. * @param scene Defines the scene to parse the data for
  33108. * @param container Defines the container attached to the parsing sequence
  33109. * @param rootUrl Defines the root url of the data
  33110. */
  33111. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33112. /**
  33113. * Gets the list of root nodes (ie. nodes with no parent)
  33114. */
  33115. rootNodes: Node[];
  33116. /** All of the cameras added to this scene
  33117. * @see http://doc.babylonjs.com/babylon101/cameras
  33118. */
  33119. cameras: Camera[];
  33120. /**
  33121. * All of the lights added to this scene
  33122. * @see http://doc.babylonjs.com/babylon101/lights
  33123. */
  33124. lights: Light[];
  33125. /**
  33126. * All of the (abstract) meshes added to this scene
  33127. */
  33128. meshes: AbstractMesh[];
  33129. /**
  33130. * The list of skeletons added to the scene
  33131. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33132. */
  33133. skeletons: Skeleton[];
  33134. /**
  33135. * All of the particle systems added to this scene
  33136. * @see http://doc.babylonjs.com/babylon101/particles
  33137. */
  33138. particleSystems: IParticleSystem[];
  33139. /**
  33140. * Gets a list of Animations associated with the scene
  33141. */
  33142. animations: Animation[];
  33143. /**
  33144. * All of the animation groups added to this scene
  33145. * @see http://doc.babylonjs.com/how_to/group
  33146. */
  33147. animationGroups: AnimationGroup[];
  33148. /**
  33149. * All of the multi-materials added to this scene
  33150. * @see http://doc.babylonjs.com/how_to/multi_materials
  33151. */
  33152. multiMaterials: MultiMaterial[];
  33153. /**
  33154. * All of the materials added to this scene
  33155. * In the context of a Scene, it is not supposed to be modified manually.
  33156. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33157. * Note also that the order of the Material wihin the array is not significant and might change.
  33158. * @see http://doc.babylonjs.com/babylon101/materials
  33159. */
  33160. materials: Material[];
  33161. /**
  33162. * The list of morph target managers added to the scene
  33163. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33164. */
  33165. morphTargetManagers: MorphTargetManager[];
  33166. /**
  33167. * The list of geometries used in the scene.
  33168. */
  33169. geometries: Geometry[];
  33170. /**
  33171. * All of the tranform nodes added to this scene
  33172. * In the context of a Scene, it is not supposed to be modified manually.
  33173. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33174. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33175. * @see http://doc.babylonjs.com/how_to/transformnode
  33176. */
  33177. transformNodes: TransformNode[];
  33178. /**
  33179. * ActionManagers available on the scene.
  33180. */
  33181. actionManagers: AbstractActionManager[];
  33182. /**
  33183. * Textures to keep.
  33184. */
  33185. textures: BaseTexture[];
  33186. /**
  33187. * Environment texture for the scene
  33188. */
  33189. environmentTexture: Nullable<BaseTexture>;
  33190. }
  33191. }
  33192. declare module BABYLON {
  33193. /**
  33194. * Defines a sound that can be played in the application.
  33195. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33197. */
  33198. export class Sound {
  33199. /**
  33200. * The name of the sound in the scene.
  33201. */
  33202. name: string;
  33203. /**
  33204. * Does the sound autoplay once loaded.
  33205. */
  33206. autoplay: boolean;
  33207. /**
  33208. * Does the sound loop after it finishes playing once.
  33209. */
  33210. loop: boolean;
  33211. /**
  33212. * Does the sound use a custom attenuation curve to simulate the falloff
  33213. * happening when the source gets further away from the camera.
  33214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33215. */
  33216. useCustomAttenuation: boolean;
  33217. /**
  33218. * The sound track id this sound belongs to.
  33219. */
  33220. soundTrackId: number;
  33221. /**
  33222. * Is this sound currently played.
  33223. */
  33224. isPlaying: boolean;
  33225. /**
  33226. * Is this sound currently paused.
  33227. */
  33228. isPaused: boolean;
  33229. /**
  33230. * Does this sound enables spatial sound.
  33231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33232. */
  33233. spatialSound: boolean;
  33234. /**
  33235. * Define the reference distance the sound should be heard perfectly.
  33236. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33237. */
  33238. refDistance: number;
  33239. /**
  33240. * Define the roll off factor of spatial sounds.
  33241. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33242. */
  33243. rolloffFactor: number;
  33244. /**
  33245. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33247. */
  33248. maxDistance: number;
  33249. /**
  33250. * Define the distance attenuation model the sound will follow.
  33251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33252. */
  33253. distanceModel: string;
  33254. /**
  33255. * @hidden
  33256. * Back Compat
  33257. **/
  33258. onended: () => any;
  33259. /**
  33260. * Observable event when the current playing sound finishes.
  33261. */
  33262. onEndedObservable: Observable<Sound>;
  33263. private _panningModel;
  33264. private _playbackRate;
  33265. private _streaming;
  33266. private _startTime;
  33267. private _startOffset;
  33268. private _position;
  33269. /** @hidden */ positionInEmitterSpace: boolean;
  33270. private _localDirection;
  33271. private _volume;
  33272. private _isReadyToPlay;
  33273. private _isDirectional;
  33274. private _readyToPlayCallback;
  33275. private _audioBuffer;
  33276. private _soundSource;
  33277. private _streamingSource;
  33278. private _soundPanner;
  33279. private _soundGain;
  33280. private _inputAudioNode;
  33281. private _outputAudioNode;
  33282. private _coneInnerAngle;
  33283. private _coneOuterAngle;
  33284. private _coneOuterGain;
  33285. private _scene;
  33286. private _connectedTransformNode;
  33287. private _customAttenuationFunction;
  33288. private _registerFunc;
  33289. private _isOutputConnected;
  33290. private _htmlAudioElement;
  33291. private _urlType;
  33292. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33293. /**
  33294. * Create a sound and attach it to a scene
  33295. * @param name Name of your sound
  33296. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33297. * @param scene defines the scene the sound belongs to
  33298. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33299. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33300. */
  33301. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33302. /**
  33303. * Release the sound and its associated resources
  33304. */
  33305. dispose(): void;
  33306. /**
  33307. * Gets if the sounds is ready to be played or not.
  33308. * @returns true if ready, otherwise false
  33309. */
  33310. isReady(): boolean;
  33311. private _soundLoaded;
  33312. /**
  33313. * Sets the data of the sound from an audiobuffer
  33314. * @param audioBuffer The audioBuffer containing the data
  33315. */
  33316. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33317. /**
  33318. * Updates the current sounds options such as maxdistance, loop...
  33319. * @param options A JSON object containing values named as the object properties
  33320. */
  33321. updateOptions(options: any): void;
  33322. private _createSpatialParameters;
  33323. private _updateSpatialParameters;
  33324. /**
  33325. * Switch the panning model to HRTF:
  33326. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33328. */
  33329. switchPanningModelToHRTF(): void;
  33330. /**
  33331. * Switch the panning model to Equal Power:
  33332. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33334. */
  33335. switchPanningModelToEqualPower(): void;
  33336. private _switchPanningModel;
  33337. /**
  33338. * Connect this sound to a sound track audio node like gain...
  33339. * @param soundTrackAudioNode the sound track audio node to connect to
  33340. */
  33341. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33342. /**
  33343. * Transform this sound into a directional source
  33344. * @param coneInnerAngle Size of the inner cone in degree
  33345. * @param coneOuterAngle Size of the outer cone in degree
  33346. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33347. */
  33348. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33349. /**
  33350. * Gets or sets the inner angle for the directional cone.
  33351. */
  33352. /**
  33353. * Gets or sets the inner angle for the directional cone.
  33354. */
  33355. directionalConeInnerAngle: number;
  33356. /**
  33357. * Gets or sets the outer angle for the directional cone.
  33358. */
  33359. /**
  33360. * Gets or sets the outer angle for the directional cone.
  33361. */
  33362. directionalConeOuterAngle: number;
  33363. /**
  33364. * Sets the position of the emitter if spatial sound is enabled
  33365. * @param newPosition Defines the new posisiton
  33366. */
  33367. setPosition(newPosition: Vector3): void;
  33368. /**
  33369. * Sets the local direction of the emitter if spatial sound is enabled
  33370. * @param newLocalDirection Defines the new local direction
  33371. */
  33372. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33373. private _updateDirection;
  33374. /** @hidden */
  33375. updateDistanceFromListener(): void;
  33376. /**
  33377. * Sets a new custom attenuation function for the sound.
  33378. * @param callback Defines the function used for the attenuation
  33379. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33380. */
  33381. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33382. /**
  33383. * Play the sound
  33384. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33385. * @param offset (optional) Start the sound setting it at a specific time
  33386. */
  33387. play(time?: number, offset?: number): void;
  33388. private _onended;
  33389. /**
  33390. * Stop the sound
  33391. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33392. */
  33393. stop(time?: number): void;
  33394. /**
  33395. * Put the sound in pause
  33396. */
  33397. pause(): void;
  33398. /**
  33399. * Sets a dedicated volume for this sounds
  33400. * @param newVolume Define the new volume of the sound
  33401. * @param time Define in how long the sound should be at this value
  33402. */
  33403. setVolume(newVolume: number, time?: number): void;
  33404. /**
  33405. * Set the sound play back rate
  33406. * @param newPlaybackRate Define the playback rate the sound should be played at
  33407. */
  33408. setPlaybackRate(newPlaybackRate: number): void;
  33409. /**
  33410. * Gets the volume of the sound.
  33411. * @returns the volume of the sound
  33412. */
  33413. getVolume(): number;
  33414. /**
  33415. * Attach the sound to a dedicated mesh
  33416. * @param transformNode The transform node to connect the sound with
  33417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33418. */
  33419. attachToMesh(transformNode: TransformNode): void;
  33420. /**
  33421. * Detach the sound from the previously attached mesh
  33422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33423. */
  33424. detachFromMesh(): void;
  33425. private _onRegisterAfterWorldMatrixUpdate;
  33426. /**
  33427. * Clone the current sound in the scene.
  33428. * @returns the new sound clone
  33429. */
  33430. clone(): Nullable<Sound>;
  33431. /**
  33432. * Gets the current underlying audio buffer containing the data
  33433. * @returns the audio buffer
  33434. */
  33435. getAudioBuffer(): Nullable<AudioBuffer>;
  33436. /**
  33437. * Serializes the Sound in a JSON representation
  33438. * @returns the JSON representation of the sound
  33439. */
  33440. serialize(): any;
  33441. /**
  33442. * Parse a JSON representation of a sound to innstantiate in a given scene
  33443. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33444. * @param scene Define the scene the new parsed sound should be created in
  33445. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33446. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33447. * @returns the newly parsed sound
  33448. */
  33449. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33450. }
  33451. }
  33452. declare module BABYLON {
  33453. /**
  33454. * This defines an action helpful to play a defined sound on a triggered action.
  33455. */
  33456. export class PlaySoundAction extends Action {
  33457. private _sound;
  33458. /**
  33459. * Instantiate the action
  33460. * @param triggerOptions defines the trigger options
  33461. * @param sound defines the sound to play
  33462. * @param condition defines the trigger related conditions
  33463. */
  33464. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33465. /** @hidden */ prepare(): void;
  33466. /**
  33467. * Execute the action and play the sound.
  33468. */
  33469. execute(): void;
  33470. /**
  33471. * Serializes the actions and its related information.
  33472. * @param parent defines the object to serialize in
  33473. * @returns the serialized object
  33474. */
  33475. serialize(parent: any): any;
  33476. }
  33477. /**
  33478. * This defines an action helpful to stop a defined sound on a triggered action.
  33479. */
  33480. export class StopSoundAction extends Action {
  33481. private _sound;
  33482. /**
  33483. * Instantiate the action
  33484. * @param triggerOptions defines the trigger options
  33485. * @param sound defines the sound to stop
  33486. * @param condition defines the trigger related conditions
  33487. */
  33488. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33489. /** @hidden */ prepare(): void;
  33490. /**
  33491. * Execute the action and stop the sound.
  33492. */
  33493. execute(): void;
  33494. /**
  33495. * Serializes the actions and its related information.
  33496. * @param parent defines the object to serialize in
  33497. * @returns the serialized object
  33498. */
  33499. serialize(parent: any): any;
  33500. }
  33501. }
  33502. declare module BABYLON {
  33503. /**
  33504. * This defines an action responsible to change the value of a property
  33505. * by interpolating between its current value and the newly set one once triggered.
  33506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33507. */
  33508. export class InterpolateValueAction extends Action {
  33509. /**
  33510. * Defines the path of the property where the value should be interpolated
  33511. */
  33512. propertyPath: string;
  33513. /**
  33514. * Defines the target value at the end of the interpolation.
  33515. */
  33516. value: any;
  33517. /**
  33518. * Defines the time it will take for the property to interpolate to the value.
  33519. */
  33520. duration: number;
  33521. /**
  33522. * Defines if the other scene animations should be stopped when the action has been triggered
  33523. */
  33524. stopOtherAnimations?: boolean;
  33525. /**
  33526. * Defines a callback raised once the interpolation animation has been done.
  33527. */
  33528. onInterpolationDone?: () => void;
  33529. /**
  33530. * Observable triggered once the interpolation animation has been done.
  33531. */
  33532. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33533. private _target;
  33534. private _effectiveTarget;
  33535. private _property;
  33536. /**
  33537. * Instantiate the action
  33538. * @param triggerOptions defines the trigger options
  33539. * @param target defines the object containing the value to interpolate
  33540. * @param propertyPath defines the path to the property in the target object
  33541. * @param value defines the target value at the end of the interpolation
  33542. * @param duration deines the time it will take for the property to interpolate to the value.
  33543. * @param condition defines the trigger related conditions
  33544. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33545. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33546. */
  33547. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33548. /** @hidden */ prepare(): void;
  33549. /**
  33550. * Execute the action starts the value interpolation.
  33551. */
  33552. execute(): void;
  33553. /**
  33554. * Serializes the actions and its related information.
  33555. * @param parent defines the object to serialize in
  33556. * @returns the serialized object
  33557. */
  33558. serialize(parent: any): any;
  33559. }
  33560. }
  33561. declare module BABYLON {
  33562. /**
  33563. * Options allowed during the creation of a sound track.
  33564. */
  33565. export interface ISoundTrackOptions {
  33566. /**
  33567. * The volume the sound track should take during creation
  33568. */
  33569. volume?: number;
  33570. /**
  33571. * Define if the sound track is the main sound track of the scene
  33572. */
  33573. mainTrack?: boolean;
  33574. }
  33575. /**
  33576. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33577. * It will be also used in a future release to apply effects on a specific track.
  33578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33579. */
  33580. export class SoundTrack {
  33581. /**
  33582. * The unique identifier of the sound track in the scene.
  33583. */
  33584. id: number;
  33585. /**
  33586. * The list of sounds included in the sound track.
  33587. */
  33588. soundCollection: Array<Sound>;
  33589. private _outputAudioNode;
  33590. private _scene;
  33591. private _isMainTrack;
  33592. private _connectedAnalyser;
  33593. private _options;
  33594. private _isInitialized;
  33595. /**
  33596. * Creates a new sound track.
  33597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33598. * @param scene Define the scene the sound track belongs to
  33599. * @param options
  33600. */
  33601. constructor(scene: Scene, options?: ISoundTrackOptions);
  33602. private _initializeSoundTrackAudioGraph;
  33603. /**
  33604. * Release the sound track and its associated resources
  33605. */
  33606. dispose(): void;
  33607. /**
  33608. * Adds a sound to this sound track
  33609. * @param sound define the cound to add
  33610. * @ignoreNaming
  33611. */
  33612. AddSound(sound: Sound): void;
  33613. /**
  33614. * Removes a sound to this sound track
  33615. * @param sound define the cound to remove
  33616. * @ignoreNaming
  33617. */
  33618. RemoveSound(sound: Sound): void;
  33619. /**
  33620. * Set a global volume for the full sound track.
  33621. * @param newVolume Define the new volume of the sound track
  33622. */
  33623. setVolume(newVolume: number): void;
  33624. /**
  33625. * Switch the panning model to HRTF:
  33626. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33628. */
  33629. switchPanningModelToHRTF(): void;
  33630. /**
  33631. * Switch the panning model to Equal Power:
  33632. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33634. */
  33635. switchPanningModelToEqualPower(): void;
  33636. /**
  33637. * Connect the sound track to an audio analyser allowing some amazing
  33638. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33640. * @param analyser The analyser to connect to the engine
  33641. */
  33642. connectToAnalyser(analyser: Analyser): void;
  33643. }
  33644. }
  33645. declare module BABYLON {
  33646. interface AbstractScene {
  33647. /**
  33648. * The list of sounds used in the scene.
  33649. */
  33650. sounds: Nullable<Array<Sound>>;
  33651. }
  33652. interface Scene {
  33653. /**
  33654. * @hidden
  33655. * Backing field
  33656. */ mainSoundTrack: SoundTrack;
  33657. /**
  33658. * The main sound track played by the scene.
  33659. * It cotains your primary collection of sounds.
  33660. */
  33661. mainSoundTrack: SoundTrack;
  33662. /**
  33663. * The list of sound tracks added to the scene
  33664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33665. */
  33666. soundTracks: Nullable<Array<SoundTrack>>;
  33667. /**
  33668. * Gets a sound using a given name
  33669. * @param name defines the name to search for
  33670. * @return the found sound or null if not found at all.
  33671. */
  33672. getSoundByName(name: string): Nullable<Sound>;
  33673. /**
  33674. * Gets or sets if audio support is enabled
  33675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33676. */
  33677. audioEnabled: boolean;
  33678. /**
  33679. * Gets or sets if audio will be output to headphones
  33680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33681. */
  33682. headphone: boolean;
  33683. }
  33684. /**
  33685. * Defines the sound scene component responsible to manage any sounds
  33686. * in a given scene.
  33687. */
  33688. export class AudioSceneComponent implements ISceneSerializableComponent {
  33689. /**
  33690. * The component name helpfull to identify the component in the list of scene components.
  33691. */
  33692. readonly name: string;
  33693. /**
  33694. * The scene the component belongs to.
  33695. */
  33696. scene: Scene;
  33697. private _audioEnabled;
  33698. /**
  33699. * Gets whether audio is enabled or not.
  33700. * Please use related enable/disable method to switch state.
  33701. */
  33702. readonly audioEnabled: boolean;
  33703. private _headphone;
  33704. /**
  33705. * Gets whether audio is outputing to headphone or not.
  33706. * Please use the according Switch methods to change output.
  33707. */
  33708. readonly headphone: boolean;
  33709. /**
  33710. * Creates a new instance of the component for the given scene
  33711. * @param scene Defines the scene to register the component in
  33712. */
  33713. constructor(scene: Scene);
  33714. /**
  33715. * Registers the component in a given scene
  33716. */
  33717. register(): void;
  33718. /**
  33719. * Rebuilds the elements related to this component in case of
  33720. * context lost for instance.
  33721. */
  33722. rebuild(): void;
  33723. /**
  33724. * Serializes the component data to the specified json object
  33725. * @param serializationObject The object to serialize to
  33726. */
  33727. serialize(serializationObject: any): void;
  33728. /**
  33729. * Adds all the element from the container to the scene
  33730. * @param container the container holding the elements
  33731. */
  33732. addFromContainer(container: AbstractScene): void;
  33733. /**
  33734. * Removes all the elements in the container from the scene
  33735. * @param container contains the elements to remove
  33736. * @param dispose if the removed element should be disposed (default: false)
  33737. */
  33738. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  33739. /**
  33740. * Disposes the component and the associated ressources.
  33741. */
  33742. dispose(): void;
  33743. /**
  33744. * Disables audio in the associated scene.
  33745. */
  33746. disableAudio(): void;
  33747. /**
  33748. * Enables audio in the associated scene.
  33749. */
  33750. enableAudio(): void;
  33751. /**
  33752. * Switch audio to headphone output.
  33753. */
  33754. switchAudioModeForHeadphones(): void;
  33755. /**
  33756. * Switch audio to normal speakers.
  33757. */
  33758. switchAudioModeForNormalSpeakers(): void;
  33759. private _afterRender;
  33760. }
  33761. }
  33762. declare module BABYLON {
  33763. /**
  33764. * Wraps one or more Sound objects and selects one with random weight for playback.
  33765. */
  33766. export class WeightedSound {
  33767. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33768. loop: boolean;
  33769. private _coneInnerAngle;
  33770. private _coneOuterAngle;
  33771. private _volume;
  33772. /** A Sound is currently playing. */
  33773. isPlaying: boolean;
  33774. /** A Sound is currently paused. */
  33775. isPaused: boolean;
  33776. private _sounds;
  33777. private _weights;
  33778. private _currentIndex?;
  33779. /**
  33780. * Creates a new WeightedSound from the list of sounds given.
  33781. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33782. * @param sounds Array of Sounds that will be selected from.
  33783. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33784. */
  33785. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33786. /**
  33787. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33788. */
  33789. /**
  33790. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33791. */
  33792. directionalConeInnerAngle: number;
  33793. /**
  33794. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33795. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33796. */
  33797. /**
  33798. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33799. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33800. */
  33801. directionalConeOuterAngle: number;
  33802. /**
  33803. * Playback volume.
  33804. */
  33805. /**
  33806. * Playback volume.
  33807. */
  33808. volume: number;
  33809. private _onended;
  33810. /**
  33811. * Suspend playback
  33812. */
  33813. pause(): void;
  33814. /**
  33815. * Stop playback
  33816. */
  33817. stop(): void;
  33818. /**
  33819. * Start playback.
  33820. * @param startOffset Position the clip head at a specific time in seconds.
  33821. */
  33822. play(startOffset?: number): void;
  33823. }
  33824. }
  33825. declare module BABYLON {
  33826. /**
  33827. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33828. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33829. */
  33830. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33831. /**
  33832. * Gets the name of the behavior.
  33833. */
  33834. readonly name: string;
  33835. /**
  33836. * The easing function used by animations
  33837. */
  33838. static EasingFunction: BackEase;
  33839. /**
  33840. * The easing mode used by animations
  33841. */
  33842. static EasingMode: number;
  33843. /**
  33844. * The duration of the animation, in milliseconds
  33845. */
  33846. transitionDuration: number;
  33847. /**
  33848. * Length of the distance animated by the transition when lower radius is reached
  33849. */
  33850. lowerRadiusTransitionRange: number;
  33851. /**
  33852. * Length of the distance animated by the transition when upper radius is reached
  33853. */
  33854. upperRadiusTransitionRange: number;
  33855. private _autoTransitionRange;
  33856. /**
  33857. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33858. */
  33859. /**
  33860. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33861. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33862. */
  33863. autoTransitionRange: boolean;
  33864. private _attachedCamera;
  33865. private _onAfterCheckInputsObserver;
  33866. private _onMeshTargetChangedObserver;
  33867. /**
  33868. * Initializes the behavior.
  33869. */
  33870. init(): void;
  33871. /**
  33872. * Attaches the behavior to its arc rotate camera.
  33873. * @param camera Defines the camera to attach the behavior to
  33874. */
  33875. attach(camera: ArcRotateCamera): void;
  33876. /**
  33877. * Detaches the behavior from its current arc rotate camera.
  33878. */
  33879. detach(): void;
  33880. private _radiusIsAnimating;
  33881. private _radiusBounceTransition;
  33882. private _animatables;
  33883. private _cachedWheelPrecision;
  33884. /**
  33885. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33886. * @param radiusLimit The limit to check against.
  33887. * @return Bool to indicate if at limit.
  33888. */
  33889. private _isRadiusAtLimit;
  33890. /**
  33891. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33892. * @param radiusDelta The delta by which to animate to. Can be negative.
  33893. */
  33894. private _applyBoundRadiusAnimation;
  33895. /**
  33896. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33897. */
  33898. protected _clearAnimationLocks(): void;
  33899. /**
  33900. * Stops and removes all animations that have been applied to the camera
  33901. */
  33902. stopAllAnimations(): void;
  33903. }
  33904. }
  33905. declare module BABYLON {
  33906. /**
  33907. * 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.
  33908. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33909. */
  33910. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33911. /**
  33912. * Gets the name of the behavior.
  33913. */
  33914. readonly name: string;
  33915. private _mode;
  33916. private _radiusScale;
  33917. private _positionScale;
  33918. private _defaultElevation;
  33919. private _elevationReturnTime;
  33920. private _elevationReturnWaitTime;
  33921. private _zoomStopsAnimation;
  33922. private _framingTime;
  33923. /**
  33924. * The easing function used by animations
  33925. */
  33926. static EasingFunction: ExponentialEase;
  33927. /**
  33928. * The easing mode used by animations
  33929. */
  33930. static EasingMode: number;
  33931. /**
  33932. * Sets the current mode used by the behavior
  33933. */
  33934. /**
  33935. * Gets current mode used by the behavior.
  33936. */
  33937. mode: number;
  33938. /**
  33939. * Sets the scale applied to the radius (1 by default)
  33940. */
  33941. /**
  33942. * Gets the scale applied to the radius
  33943. */
  33944. radiusScale: number;
  33945. /**
  33946. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33947. */
  33948. /**
  33949. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33950. */
  33951. positionScale: number;
  33952. /**
  33953. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33954. * behaviour is triggered, in radians.
  33955. */
  33956. /**
  33957. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33958. * behaviour is triggered, in radians.
  33959. */
  33960. defaultElevation: number;
  33961. /**
  33962. * Sets the time (in milliseconds) taken to return to the default beta position.
  33963. * Negative value indicates camera should not return to default.
  33964. */
  33965. /**
  33966. * Gets the time (in milliseconds) taken to return to the default beta position.
  33967. * Negative value indicates camera should not return to default.
  33968. */
  33969. elevationReturnTime: number;
  33970. /**
  33971. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33972. */
  33973. /**
  33974. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33975. */
  33976. elevationReturnWaitTime: number;
  33977. /**
  33978. * Sets the flag that indicates if user zooming should stop animation.
  33979. */
  33980. /**
  33981. * Gets the flag that indicates if user zooming should stop animation.
  33982. */
  33983. zoomStopsAnimation: boolean;
  33984. /**
  33985. * Sets the transition time when framing the mesh, in milliseconds
  33986. */
  33987. /**
  33988. * Gets the transition time when framing the mesh, in milliseconds
  33989. */
  33990. framingTime: number;
  33991. /**
  33992. * Define if the behavior should automatically change the configured
  33993. * camera limits and sensibilities.
  33994. */
  33995. autoCorrectCameraLimitsAndSensibility: boolean;
  33996. private _onPrePointerObservableObserver;
  33997. private _onAfterCheckInputsObserver;
  33998. private _onMeshTargetChangedObserver;
  33999. private _attachedCamera;
  34000. private _isPointerDown;
  34001. private _lastInteractionTime;
  34002. /**
  34003. * Initializes the behavior.
  34004. */
  34005. init(): void;
  34006. /**
  34007. * Attaches the behavior to its arc rotate camera.
  34008. * @param camera Defines the camera to attach the behavior to
  34009. */
  34010. attach(camera: ArcRotateCamera): void;
  34011. /**
  34012. * Detaches the behavior from its current arc rotate camera.
  34013. */
  34014. detach(): void;
  34015. private _animatables;
  34016. private _betaIsAnimating;
  34017. private _betaTransition;
  34018. private _radiusTransition;
  34019. private _vectorTransition;
  34020. /**
  34021. * Targets the given mesh and updates zoom level accordingly.
  34022. * @param mesh The mesh to target.
  34023. * @param radius Optional. If a cached radius position already exists, overrides default.
  34024. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34025. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34026. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34027. */
  34028. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34029. /**
  34030. * Targets the given mesh with its children and updates zoom level accordingly.
  34031. * @param mesh The mesh to target.
  34032. * @param radius Optional. If a cached radius position already exists, overrides default.
  34033. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34034. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34035. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34036. */
  34037. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34038. /**
  34039. * Targets the given meshes with their children and updates zoom level accordingly.
  34040. * @param meshes The mesh to target.
  34041. * @param radius Optional. If a cached radius position already exists, overrides default.
  34042. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34043. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34044. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34045. */
  34046. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34047. /**
  34048. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34049. * @param minimumWorld Determines the smaller position of the bounding box extend
  34050. * @param maximumWorld Determines the bigger position of the bounding box extend
  34051. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34052. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34053. */
  34054. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34055. /**
  34056. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34057. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34058. * frustum width.
  34059. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34060. * to fully enclose the mesh in the viewing frustum.
  34061. */
  34062. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34063. /**
  34064. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34065. * is automatically returned to its default position (expected to be above ground plane).
  34066. */
  34067. private _maintainCameraAboveGround;
  34068. /**
  34069. * Returns the frustum slope based on the canvas ratio and camera FOV
  34070. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34071. */
  34072. private _getFrustumSlope;
  34073. /**
  34074. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34075. */
  34076. private _clearAnimationLocks;
  34077. /**
  34078. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34079. */
  34080. private _applyUserInteraction;
  34081. /**
  34082. * Stops and removes all animations that have been applied to the camera
  34083. */
  34084. stopAllAnimations(): void;
  34085. /**
  34086. * Gets a value indicating if the user is moving the camera
  34087. */
  34088. readonly isUserIsMoving: boolean;
  34089. /**
  34090. * The camera can move all the way towards the mesh.
  34091. */
  34092. static IgnoreBoundsSizeMode: number;
  34093. /**
  34094. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34095. */
  34096. static FitFrustumSidesMode: number;
  34097. }
  34098. }
  34099. declare module BABYLON {
  34100. /**
  34101. * Base class for Camera Pointer Inputs.
  34102. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34103. * for example usage.
  34104. */
  34105. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34106. /**
  34107. * Defines the camera the input is attached to.
  34108. */
  34109. abstract camera: Camera;
  34110. /**
  34111. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34112. */
  34113. protected _altKey: boolean;
  34114. protected _ctrlKey: boolean;
  34115. protected _metaKey: boolean;
  34116. protected _shiftKey: boolean;
  34117. /**
  34118. * Which mouse buttons were pressed at time of last mouse event.
  34119. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34120. */
  34121. protected _buttonsPressed: number;
  34122. /**
  34123. * Defines the buttons associated with the input to handle camera move.
  34124. */
  34125. buttons: number[];
  34126. /**
  34127. * Attach the input controls to a specific dom element to get the input from.
  34128. * @param element Defines the element the controls should be listened from
  34129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34130. */
  34131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34132. /**
  34133. * Detach the current controls from the specified dom element.
  34134. * @param element Defines the element to stop listening the inputs from
  34135. */
  34136. detachControl(element: Nullable<HTMLElement>): void;
  34137. /**
  34138. * Gets the class name of the current input.
  34139. * @returns the class name
  34140. */
  34141. getClassName(): string;
  34142. /**
  34143. * Get the friendly name associated with the input class.
  34144. * @returns the input friendly name
  34145. */
  34146. getSimpleName(): string;
  34147. /**
  34148. * Called on pointer POINTERDOUBLETAP event.
  34149. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34150. */
  34151. protected onDoubleTap(type: string): void;
  34152. /**
  34153. * Called on pointer POINTERMOVE event if only a single touch is active.
  34154. * Override this method to provide functionality.
  34155. */
  34156. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34157. /**
  34158. * Called on pointer POINTERMOVE event if multiple touches are active.
  34159. * Override this method to provide functionality.
  34160. */
  34161. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34162. /**
  34163. * Called on JS contextmenu event.
  34164. * Override this method to provide functionality.
  34165. */
  34166. protected onContextMenu(evt: PointerEvent): void;
  34167. /**
  34168. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34169. * press.
  34170. * Override this method to provide functionality.
  34171. */
  34172. protected onButtonDown(evt: PointerEvent): void;
  34173. /**
  34174. * Called each time a new POINTERUP event occurs. Ie, for each button
  34175. * release.
  34176. * Override this method to provide functionality.
  34177. */
  34178. protected onButtonUp(evt: PointerEvent): void;
  34179. /**
  34180. * Called when window becomes inactive.
  34181. * Override this method to provide functionality.
  34182. */
  34183. protected onLostFocus(): void;
  34184. private _pointerInput;
  34185. private _observer;
  34186. private _onLostFocus;
  34187. private pointA;
  34188. private pointB;
  34189. }
  34190. }
  34191. declare module BABYLON {
  34192. /**
  34193. * Manage the pointers inputs to control an arc rotate camera.
  34194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34195. */
  34196. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34197. /**
  34198. * Defines the camera the input is attached to.
  34199. */
  34200. camera: ArcRotateCamera;
  34201. /**
  34202. * Gets the class name of the current input.
  34203. * @returns the class name
  34204. */
  34205. getClassName(): string;
  34206. /**
  34207. * Defines the buttons associated with the input to handle camera move.
  34208. */
  34209. buttons: number[];
  34210. /**
  34211. * Defines the pointer angular sensibility along the X axis or how fast is
  34212. * the camera rotating.
  34213. */
  34214. angularSensibilityX: number;
  34215. /**
  34216. * Defines the pointer angular sensibility along the Y axis or how fast is
  34217. * the camera rotating.
  34218. */
  34219. angularSensibilityY: number;
  34220. /**
  34221. * Defines the pointer pinch precision or how fast is the camera zooming.
  34222. */
  34223. pinchPrecision: number;
  34224. /**
  34225. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34226. * from 0.
  34227. * It defines the percentage of current camera.radius to use as delta when
  34228. * pinch zoom is used.
  34229. */
  34230. pinchDeltaPercentage: number;
  34231. /**
  34232. * Defines the pointer panning sensibility or how fast is the camera moving.
  34233. */
  34234. panningSensibility: number;
  34235. /**
  34236. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34237. */
  34238. multiTouchPanning: boolean;
  34239. /**
  34240. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34241. * zoom (pinch) through multitouch.
  34242. */
  34243. multiTouchPanAndZoom: boolean;
  34244. /**
  34245. * Revers pinch action direction.
  34246. */
  34247. pinchInwards: boolean;
  34248. private _isPanClick;
  34249. private _twoFingerActivityCount;
  34250. private _isPinching;
  34251. /**
  34252. * Called on pointer POINTERMOVE event if only a single touch is active.
  34253. */
  34254. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34255. /**
  34256. * Called on pointer POINTERDOUBLETAP event.
  34257. */
  34258. protected onDoubleTap(type: string): void;
  34259. /**
  34260. * Called on pointer POINTERMOVE event if multiple touches are active.
  34261. */
  34262. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34263. /**
  34264. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34265. * press.
  34266. */
  34267. protected onButtonDown(evt: PointerEvent): void;
  34268. /**
  34269. * Called each time a new POINTERUP event occurs. Ie, for each button
  34270. * release.
  34271. */
  34272. protected onButtonUp(evt: PointerEvent): void;
  34273. /**
  34274. * Called when window becomes inactive.
  34275. */
  34276. protected onLostFocus(): void;
  34277. }
  34278. }
  34279. declare module BABYLON {
  34280. /**
  34281. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34283. */
  34284. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34285. /**
  34286. * Defines the camera the input is attached to.
  34287. */
  34288. camera: ArcRotateCamera;
  34289. /**
  34290. * Defines the list of key codes associated with the up action (increase alpha)
  34291. */
  34292. keysUp: number[];
  34293. /**
  34294. * Defines the list of key codes associated with the down action (decrease alpha)
  34295. */
  34296. keysDown: number[];
  34297. /**
  34298. * Defines the list of key codes associated with the left action (increase beta)
  34299. */
  34300. keysLeft: number[];
  34301. /**
  34302. * Defines the list of key codes associated with the right action (decrease beta)
  34303. */
  34304. keysRight: number[];
  34305. /**
  34306. * Defines the list of key codes associated with the reset action.
  34307. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34308. */
  34309. keysReset: number[];
  34310. /**
  34311. * Defines the panning sensibility of the inputs.
  34312. * (How fast is the camera paning)
  34313. */
  34314. panningSensibility: number;
  34315. /**
  34316. * Defines the zooming sensibility of the inputs.
  34317. * (How fast is the camera zooming)
  34318. */
  34319. zoomingSensibility: number;
  34320. /**
  34321. * Defines wether maintaining the alt key down switch the movement mode from
  34322. * orientation to zoom.
  34323. */
  34324. useAltToZoom: boolean;
  34325. /**
  34326. * Rotation speed of the camera
  34327. */
  34328. angularSpeed: number;
  34329. private _keys;
  34330. private _ctrlPressed;
  34331. private _altPressed;
  34332. private _onCanvasBlurObserver;
  34333. private _onKeyboardObserver;
  34334. private _engine;
  34335. private _scene;
  34336. /**
  34337. * Attach the input controls to a specific dom element to get the input from.
  34338. * @param element Defines the element the controls should be listened from
  34339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34340. */
  34341. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34342. /**
  34343. * Detach the current controls from the specified dom element.
  34344. * @param element Defines the element to stop listening the inputs from
  34345. */
  34346. detachControl(element: Nullable<HTMLElement>): void;
  34347. /**
  34348. * Update the current camera state depending on the inputs that have been used this frame.
  34349. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34350. */
  34351. checkInputs(): void;
  34352. /**
  34353. * Gets the class name of the current intput.
  34354. * @returns the class name
  34355. */
  34356. getClassName(): string;
  34357. /**
  34358. * Get the friendly name associated with the input class.
  34359. * @returns the input friendly name
  34360. */
  34361. getSimpleName(): string;
  34362. }
  34363. }
  34364. declare module BABYLON {
  34365. /**
  34366. * Manage the mouse wheel inputs to control an arc rotate camera.
  34367. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34368. */
  34369. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34370. /**
  34371. * Defines the camera the input is attached to.
  34372. */
  34373. camera: ArcRotateCamera;
  34374. /**
  34375. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34376. */
  34377. wheelPrecision: number;
  34378. /**
  34379. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34380. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34381. */
  34382. wheelDeltaPercentage: number;
  34383. private _wheel;
  34384. private _observer;
  34385. /**
  34386. * Attach the input controls to a specific dom element to get the input from.
  34387. * @param element Defines the element the controls should be listened from
  34388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34389. */
  34390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34391. /**
  34392. * Detach the current controls from the specified dom element.
  34393. * @param element Defines the element to stop listening the inputs from
  34394. */
  34395. detachControl(element: Nullable<HTMLElement>): void;
  34396. /**
  34397. * Gets the class name of the current intput.
  34398. * @returns the class name
  34399. */
  34400. getClassName(): string;
  34401. /**
  34402. * Get the friendly name associated with the input class.
  34403. * @returns the input friendly name
  34404. */
  34405. getSimpleName(): string;
  34406. }
  34407. }
  34408. declare module BABYLON {
  34409. /**
  34410. * Default Inputs manager for the ArcRotateCamera.
  34411. * It groups all the default supported inputs for ease of use.
  34412. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34413. */
  34414. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34415. /**
  34416. * Instantiates a new ArcRotateCameraInputsManager.
  34417. * @param camera Defines the camera the inputs belong to
  34418. */
  34419. constructor(camera: ArcRotateCamera);
  34420. /**
  34421. * Add mouse wheel input support to the input manager.
  34422. * @returns the current input manager
  34423. */
  34424. addMouseWheel(): ArcRotateCameraInputsManager;
  34425. /**
  34426. * Add pointers input support to the input manager.
  34427. * @returns the current input manager
  34428. */
  34429. addPointers(): ArcRotateCameraInputsManager;
  34430. /**
  34431. * Add keyboard input support to the input manager.
  34432. * @returns the current input manager
  34433. */
  34434. addKeyboard(): ArcRotateCameraInputsManager;
  34435. }
  34436. }
  34437. declare module BABYLON {
  34438. /**
  34439. * This represents an orbital type of camera.
  34440. *
  34441. * 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.
  34442. * 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.
  34443. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34444. */
  34445. export class ArcRotateCamera extends TargetCamera {
  34446. /**
  34447. * Defines the rotation angle of the camera along the longitudinal axis.
  34448. */
  34449. alpha: number;
  34450. /**
  34451. * Defines the rotation angle of the camera along the latitudinal axis.
  34452. */
  34453. beta: number;
  34454. /**
  34455. * Defines the radius of the camera from it s target point.
  34456. */
  34457. radius: number;
  34458. protected _target: Vector3;
  34459. protected _targetHost: Nullable<AbstractMesh>;
  34460. /**
  34461. * Defines the target point of the camera.
  34462. * The camera looks towards it form the radius distance.
  34463. */
  34464. target: Vector3;
  34465. /**
  34466. * Define the current local position of the camera in the scene
  34467. */
  34468. position: Vector3;
  34469. protected _upVector: Vector3;
  34470. protected _upToYMatrix: Matrix;
  34471. protected _YToUpMatrix: Matrix;
  34472. /**
  34473. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34474. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34475. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34476. */
  34477. upVector: Vector3;
  34478. /**
  34479. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34480. */
  34481. setMatUp(): void;
  34482. /**
  34483. * Current inertia value on the longitudinal axis.
  34484. * The bigger this number the longer it will take for the camera to stop.
  34485. */
  34486. inertialAlphaOffset: number;
  34487. /**
  34488. * Current inertia value on the latitudinal axis.
  34489. * The bigger this number the longer it will take for the camera to stop.
  34490. */
  34491. inertialBetaOffset: number;
  34492. /**
  34493. * Current inertia value on the radius axis.
  34494. * The bigger this number the longer it will take for the camera to stop.
  34495. */
  34496. inertialRadiusOffset: number;
  34497. /**
  34498. * Minimum allowed angle on the longitudinal axis.
  34499. * This can help limiting how the Camera is able to move in the scene.
  34500. */
  34501. lowerAlphaLimit: Nullable<number>;
  34502. /**
  34503. * Maximum allowed angle on the longitudinal axis.
  34504. * This can help limiting how the Camera is able to move in the scene.
  34505. */
  34506. upperAlphaLimit: Nullable<number>;
  34507. /**
  34508. * Minimum allowed angle on the latitudinal axis.
  34509. * This can help limiting how the Camera is able to move in the scene.
  34510. */
  34511. lowerBetaLimit: number;
  34512. /**
  34513. * Maximum allowed angle on the latitudinal axis.
  34514. * This can help limiting how the Camera is able to move in the scene.
  34515. */
  34516. upperBetaLimit: number;
  34517. /**
  34518. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34519. * This can help limiting how the Camera is able to move in the scene.
  34520. */
  34521. lowerRadiusLimit: Nullable<number>;
  34522. /**
  34523. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34524. * This can help limiting how the Camera is able to move in the scene.
  34525. */
  34526. upperRadiusLimit: Nullable<number>;
  34527. /**
  34528. * Defines the current inertia value used during panning of the camera along the X axis.
  34529. */
  34530. inertialPanningX: number;
  34531. /**
  34532. * Defines the current inertia value used during panning of the camera along the Y axis.
  34533. */
  34534. inertialPanningY: number;
  34535. /**
  34536. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34537. * Basically if your fingers moves away from more than this distance you will be considered
  34538. * in pinch mode.
  34539. */
  34540. pinchToPanMaxDistance: number;
  34541. /**
  34542. * Defines the maximum distance the camera can pan.
  34543. * This could help keeping the cammera always in your scene.
  34544. */
  34545. panningDistanceLimit: Nullable<number>;
  34546. /**
  34547. * Defines the target of the camera before paning.
  34548. */
  34549. panningOriginTarget: Vector3;
  34550. /**
  34551. * Defines the value of the inertia used during panning.
  34552. * 0 would mean stop inertia and one would mean no decelleration at all.
  34553. */
  34554. panningInertia: number;
  34555. /**
  34556. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34557. */
  34558. angularSensibilityX: number;
  34559. /**
  34560. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34561. */
  34562. angularSensibilityY: number;
  34563. /**
  34564. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34565. */
  34566. pinchPrecision: number;
  34567. /**
  34568. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34569. * It will be used instead of pinchDeltaPrecision if different from 0.
  34570. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34571. */
  34572. pinchDeltaPercentage: number;
  34573. /**
  34574. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34575. */
  34576. panningSensibility: number;
  34577. /**
  34578. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34579. */
  34580. keysUp: number[];
  34581. /**
  34582. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34583. */
  34584. keysDown: number[];
  34585. /**
  34586. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34587. */
  34588. keysLeft: number[];
  34589. /**
  34590. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34591. */
  34592. keysRight: number[];
  34593. /**
  34594. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34595. */
  34596. wheelPrecision: number;
  34597. /**
  34598. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34599. * It will be used instead of pinchDeltaPrecision if different from 0.
  34600. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34601. */
  34602. wheelDeltaPercentage: number;
  34603. /**
  34604. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34605. */
  34606. zoomOnFactor: number;
  34607. /**
  34608. * Defines a screen offset for the camera position.
  34609. */
  34610. targetScreenOffset: Vector2;
  34611. /**
  34612. * Allows the camera to be completely reversed.
  34613. * If false the camera can not arrive upside down.
  34614. */
  34615. allowUpsideDown: boolean;
  34616. /**
  34617. * Define if double tap/click is used to restore the previously saved state of the camera.
  34618. */
  34619. useInputToRestoreState: boolean;
  34620. /** @hidden */ viewMatrix: Matrix;
  34621. /** @hidden */ useCtrlForPanning: boolean;
  34622. /** @hidden */ panningMouseButton: number;
  34623. /**
  34624. * Defines the input associated to the camera.
  34625. */
  34626. inputs: ArcRotateCameraInputsManager;
  34627. /** @hidden */ reset: () => void;
  34628. /**
  34629. * Defines the allowed panning axis.
  34630. */
  34631. panningAxis: Vector3;
  34632. protected _localDirection: Vector3;
  34633. protected _transformedDirection: Vector3;
  34634. private _bouncingBehavior;
  34635. /**
  34636. * Gets the bouncing behavior of the camera if it has been enabled.
  34637. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34638. */
  34639. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34640. /**
  34641. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34642. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34643. */
  34644. useBouncingBehavior: boolean;
  34645. private _framingBehavior;
  34646. /**
  34647. * Gets the framing behavior of the camera if it has been enabled.
  34648. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34649. */
  34650. readonly framingBehavior: Nullable<FramingBehavior>;
  34651. /**
  34652. * Defines if the framing behavior of the camera is enabled on the camera.
  34653. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34654. */
  34655. useFramingBehavior: boolean;
  34656. private _autoRotationBehavior;
  34657. /**
  34658. * Gets the auto rotation behavior of the camera if it has been enabled.
  34659. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34660. */
  34661. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34662. /**
  34663. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34664. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34665. */
  34666. useAutoRotationBehavior: boolean;
  34667. /**
  34668. * Observable triggered when the mesh target has been changed on the camera.
  34669. */
  34670. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34671. /**
  34672. * Event raised when the camera is colliding with a mesh.
  34673. */
  34674. onCollide: (collidedMesh: AbstractMesh) => void;
  34675. /**
  34676. * Defines whether the camera should check collision with the objects oh the scene.
  34677. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34678. */
  34679. checkCollisions: boolean;
  34680. /**
  34681. * Defines the collision radius of the camera.
  34682. * This simulates a sphere around the camera.
  34683. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34684. */
  34685. collisionRadius: Vector3;
  34686. protected _collider: Collider;
  34687. protected _previousPosition: Vector3;
  34688. protected _collisionVelocity: Vector3;
  34689. protected _newPosition: Vector3;
  34690. protected _previousAlpha: number;
  34691. protected _previousBeta: number;
  34692. protected _previousRadius: number;
  34693. protected _collisionTriggered: boolean;
  34694. protected _targetBoundingCenter: Nullable<Vector3>;
  34695. private _computationVector;
  34696. /**
  34697. * Instantiates a new ArcRotateCamera in a given scene
  34698. * @param name Defines the name of the camera
  34699. * @param alpha Defines the camera rotation along the logitudinal axis
  34700. * @param beta Defines the camera rotation along the latitudinal axis
  34701. * @param radius Defines the camera distance from its target
  34702. * @param target Defines the camera target
  34703. * @param scene Defines the scene the camera belongs to
  34704. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34705. */
  34706. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34707. /** @hidden */ initCache(): void;
  34708. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  34709. protected _getTargetPosition(): Vector3;
  34710. private _storedAlpha;
  34711. private _storedBeta;
  34712. private _storedRadius;
  34713. private _storedTarget;
  34714. /**
  34715. * Stores the current state of the camera (alpha, beta, radius and target)
  34716. * @returns the camera itself
  34717. */
  34718. storeState(): Camera;
  34719. /**
  34720. * @hidden
  34721. * Restored camera state. You must call storeState() first
  34722. */ restoreStateValues(): boolean;
  34723. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  34724. /**
  34725. * Attached controls to the current camera.
  34726. * @param element Defines the element the controls should be listened from
  34727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34728. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34729. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34730. */
  34731. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34732. /**
  34733. * Detach the current controls from the camera.
  34734. * The camera will stop reacting to inputs.
  34735. * @param element Defines the element to stop listening the inputs from
  34736. */
  34737. detachControl(element: HTMLElement): void;
  34738. /** @hidden */ checkInputs(): void;
  34739. protected _checkLimits(): void;
  34740. /**
  34741. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34742. */
  34743. rebuildAnglesAndRadius(): void;
  34744. /**
  34745. * Use a position to define the current camera related information like aplha, beta and radius
  34746. * @param position Defines the position to set the camera at
  34747. */
  34748. setPosition(position: Vector3): void;
  34749. /**
  34750. * Defines the target the camera should look at.
  34751. * This will automatically adapt alpha beta and radius to fit within the new target.
  34752. * @param target Defines the new target as a Vector or a mesh
  34753. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34754. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34755. */
  34756. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34757. /** @hidden */ getViewMatrix(): Matrix;
  34758. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34759. /**
  34760. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34761. * @param meshes Defines the mesh to zoom on
  34762. * @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)
  34763. */
  34764. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34765. /**
  34766. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34767. * The target will be changed but the radius
  34768. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34769. * @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)
  34770. */
  34771. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34772. min: Vector3;
  34773. max: Vector3;
  34774. distance: number;
  34775. }, doNotUpdateMaxZ?: boolean): void;
  34776. /**
  34777. * @override
  34778. * Override Camera.createRigCamera
  34779. */
  34780. createRigCamera(name: string, cameraIndex: number): Camera;
  34781. /**
  34782. * @hidden
  34783. * @override
  34784. * Override Camera._updateRigCameras
  34785. */ updateRigCameras(): void;
  34786. /**
  34787. * Destroy the camera and release the current resources hold by it.
  34788. */
  34789. dispose(): void;
  34790. /**
  34791. * Gets the current object class name.
  34792. * @return the class name
  34793. */
  34794. getClassName(): string;
  34795. }
  34796. }
  34797. declare module BABYLON {
  34798. /**
  34799. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34800. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34801. */
  34802. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34803. /**
  34804. * Gets the name of the behavior.
  34805. */
  34806. readonly name: string;
  34807. private _zoomStopsAnimation;
  34808. private _idleRotationSpeed;
  34809. private _idleRotationWaitTime;
  34810. private _idleRotationSpinupTime;
  34811. /**
  34812. * Sets the flag that indicates if user zooming should stop animation.
  34813. */
  34814. /**
  34815. * Gets the flag that indicates if user zooming should stop animation.
  34816. */
  34817. zoomStopsAnimation: boolean;
  34818. /**
  34819. * Sets the default speed at which the camera rotates around the model.
  34820. */
  34821. /**
  34822. * Gets the default speed at which the camera rotates around the model.
  34823. */
  34824. idleRotationSpeed: number;
  34825. /**
  34826. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34827. */
  34828. /**
  34829. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34830. */
  34831. idleRotationWaitTime: number;
  34832. /**
  34833. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34834. */
  34835. /**
  34836. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34837. */
  34838. idleRotationSpinupTime: number;
  34839. /**
  34840. * Gets a value indicating if the camera is currently rotating because of this behavior
  34841. */
  34842. readonly rotationInProgress: boolean;
  34843. private _onPrePointerObservableObserver;
  34844. private _onAfterCheckInputsObserver;
  34845. private _attachedCamera;
  34846. private _isPointerDown;
  34847. private _lastFrameTime;
  34848. private _lastInteractionTime;
  34849. private _cameraRotationSpeed;
  34850. /**
  34851. * Initializes the behavior.
  34852. */
  34853. init(): void;
  34854. /**
  34855. * Attaches the behavior to its arc rotate camera.
  34856. * @param camera Defines the camera to attach the behavior to
  34857. */
  34858. attach(camera: ArcRotateCamera): void;
  34859. /**
  34860. * Detaches the behavior from its current arc rotate camera.
  34861. */
  34862. detach(): void;
  34863. /**
  34864. * Returns true if user is scrolling.
  34865. * @return true if user is scrolling.
  34866. */
  34867. private _userIsZooming;
  34868. private _lastFrameRadius;
  34869. private _shouldAnimationStopForInteraction;
  34870. /**
  34871. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34872. */
  34873. private _applyUserInteraction;
  34874. private _userIsMoving;
  34875. }
  34876. }
  34877. declare module BABYLON {
  34878. /**
  34879. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34880. */
  34881. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34882. private ui;
  34883. /**
  34884. * The name of the behavior
  34885. */
  34886. name: string;
  34887. /**
  34888. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34889. */
  34890. distanceAwayFromFace: number;
  34891. /**
  34892. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34893. */
  34894. distanceAwayFromBottomOfFace: number;
  34895. private _faceVectors;
  34896. private _target;
  34897. private _scene;
  34898. private _onRenderObserver;
  34899. private _tmpMatrix;
  34900. private _tmpVector;
  34901. /**
  34902. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34903. * @param ui The transform node that should be attched to the mesh
  34904. */
  34905. constructor(ui: TransformNode);
  34906. /**
  34907. * Initializes the behavior
  34908. */
  34909. init(): void;
  34910. private _closestFace;
  34911. private _zeroVector;
  34912. private _lookAtTmpMatrix;
  34913. private _lookAtToRef;
  34914. /**
  34915. * Attaches the AttachToBoxBehavior to the passed in mesh
  34916. * @param target The mesh that the specified node will be attached to
  34917. */
  34918. attach(target: Mesh): void;
  34919. /**
  34920. * Detaches the behavior from the mesh
  34921. */
  34922. detach(): void;
  34923. }
  34924. }
  34925. declare module BABYLON {
  34926. /**
  34927. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34928. */
  34929. export class FadeInOutBehavior implements Behavior<Mesh> {
  34930. /**
  34931. * Time in milliseconds to delay before fading in (Default: 0)
  34932. */
  34933. delay: number;
  34934. /**
  34935. * Time in milliseconds for the mesh to fade in (Default: 300)
  34936. */
  34937. fadeInTime: number;
  34938. private _millisecondsPerFrame;
  34939. private _hovered;
  34940. private _hoverValue;
  34941. private _ownerNode;
  34942. /**
  34943. * Instatiates the FadeInOutBehavior
  34944. */
  34945. constructor();
  34946. /**
  34947. * The name of the behavior
  34948. */
  34949. readonly name: string;
  34950. /**
  34951. * Initializes the behavior
  34952. */
  34953. init(): void;
  34954. /**
  34955. * Attaches the fade behavior on the passed in mesh
  34956. * @param ownerNode The mesh that will be faded in/out once attached
  34957. */
  34958. attach(ownerNode: Mesh): void;
  34959. /**
  34960. * Detaches the behavior from the mesh
  34961. */
  34962. detach(): void;
  34963. /**
  34964. * Triggers the mesh to begin fading in or out
  34965. * @param value if the object should fade in or out (true to fade in)
  34966. */
  34967. fadeIn(value: boolean): void;
  34968. private _update;
  34969. private _setAllVisibility;
  34970. }
  34971. }
  34972. declare module BABYLON {
  34973. /**
  34974. * Class containing a set of static utilities functions for managing Pivots
  34975. * @hidden
  34976. */
  34977. export class PivotTools {
  34978. private static _PivotCached;
  34979. private static _OldPivotPoint;
  34980. private static _PivotTranslation;
  34981. private static _PivotTmpVector;
  34982. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34983. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  34984. }
  34985. }
  34986. declare module BABYLON {
  34987. /**
  34988. * Class containing static functions to help procedurally build meshes
  34989. */
  34990. export class PlaneBuilder {
  34991. /**
  34992. * Creates a plane mesh
  34993. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  34994. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  34995. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  34996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34997. * * 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
  34998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34999. * @param name defines the name of the mesh
  35000. * @param options defines the options used to create the mesh
  35001. * @param scene defines the hosting scene
  35002. * @returns the plane mesh
  35003. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35004. */
  35005. static CreatePlane(name: string, options: {
  35006. size?: number;
  35007. width?: number;
  35008. height?: number;
  35009. sideOrientation?: number;
  35010. frontUVs?: Vector4;
  35011. backUVs?: Vector4;
  35012. updatable?: boolean;
  35013. sourcePlane?: Plane;
  35014. }, scene?: Nullable<Scene>): Mesh;
  35015. }
  35016. }
  35017. declare module BABYLON {
  35018. /**
  35019. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35020. */
  35021. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35022. private static _AnyMouseID;
  35023. private _attachedNode;
  35024. private _dragPlane;
  35025. private _scene;
  35026. private _pointerObserver;
  35027. private _beforeRenderObserver;
  35028. private static _planeScene;
  35029. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35030. /**
  35031. * 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)
  35032. */
  35033. maxDragAngle: number;
  35034. /**
  35035. * @hidden
  35036. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  35037. /**
  35038. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35039. */
  35040. currentDraggingPointerID: number;
  35041. /**
  35042. * The last position where the pointer hit the drag plane in world space
  35043. */
  35044. lastDragPosition: Vector3;
  35045. /**
  35046. * If the behavior is currently in a dragging state
  35047. */
  35048. dragging: boolean;
  35049. /**
  35050. * 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)
  35051. */
  35052. dragDeltaRatio: number;
  35053. /**
  35054. * If the drag plane orientation should be updated during the dragging (Default: true)
  35055. */
  35056. updateDragPlane: boolean;
  35057. private _debugMode;
  35058. private _moving;
  35059. /**
  35060. * Fires each time the attached mesh is dragged with the pointer
  35061. * * delta between last drag position and current drag position in world space
  35062. * * dragDistance along the drag axis
  35063. * * dragPlaneNormal normal of the current drag plane used during the drag
  35064. * * dragPlanePoint in world space where the drag intersects the drag plane
  35065. */
  35066. onDragObservable: Observable<{
  35067. delta: Vector3;
  35068. dragPlanePoint: Vector3;
  35069. dragPlaneNormal: Vector3;
  35070. dragDistance: number;
  35071. pointerId: number;
  35072. }>;
  35073. /**
  35074. * Fires each time a drag begins (eg. mouse down on mesh)
  35075. */
  35076. onDragStartObservable: Observable<{
  35077. dragPlanePoint: Vector3;
  35078. pointerId: number;
  35079. }>;
  35080. /**
  35081. * Fires each time a drag ends (eg. mouse release after drag)
  35082. */
  35083. onDragEndObservable: Observable<{
  35084. dragPlanePoint: Vector3;
  35085. pointerId: number;
  35086. }>;
  35087. /**
  35088. * If the attached mesh should be moved when dragged
  35089. */
  35090. moveAttached: boolean;
  35091. /**
  35092. * If the drag behavior will react to drag events (Default: true)
  35093. */
  35094. enabled: boolean;
  35095. /**
  35096. * If camera controls should be detached during the drag
  35097. */
  35098. detachCameraControls: boolean;
  35099. /**
  35100. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35101. */
  35102. useObjectOrienationForDragging: boolean;
  35103. private _options;
  35104. /**
  35105. * Creates a pointer drag behavior that can be attached to a mesh
  35106. * @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)
  35107. */
  35108. constructor(options?: {
  35109. dragAxis?: Vector3;
  35110. dragPlaneNormal?: Vector3;
  35111. });
  35112. /**
  35113. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35114. */
  35115. validateDrag: (targetPosition: Vector3) => boolean;
  35116. /**
  35117. * The name of the behavior
  35118. */
  35119. readonly name: string;
  35120. /**
  35121. * Initializes the behavior
  35122. */
  35123. init(): void;
  35124. private _tmpVector;
  35125. private _alternatePickedPoint;
  35126. private _worldDragAxis;
  35127. private _targetPosition;
  35128. private _attachedElement;
  35129. /**
  35130. * Attaches the drag behavior the passed in mesh
  35131. * @param ownerNode The mesh that will be dragged around once attached
  35132. */
  35133. attach(ownerNode: AbstractMesh): void;
  35134. /**
  35135. * Force relase the drag action by code.
  35136. */
  35137. releaseDrag(): void;
  35138. private _startDragRay;
  35139. private _lastPointerRay;
  35140. /**
  35141. * Simulates the start of a pointer drag event on the behavior
  35142. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35143. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35144. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35145. */
  35146. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35147. private _startDrag;
  35148. private _dragDelta;
  35149. private _moveDrag;
  35150. private _pickWithRayOnDragPlane;
  35151. private _pointA;
  35152. private _pointB;
  35153. private _pointC;
  35154. private _lineA;
  35155. private _lineB;
  35156. private _localAxis;
  35157. private _lookAt;
  35158. private _updateDragPlanePosition;
  35159. /**
  35160. * Detaches the behavior from the mesh
  35161. */
  35162. detach(): void;
  35163. }
  35164. }
  35165. declare module BABYLON {
  35166. /**
  35167. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35168. */
  35169. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35170. private _dragBehaviorA;
  35171. private _dragBehaviorB;
  35172. private _startDistance;
  35173. private _initialScale;
  35174. private _targetScale;
  35175. private _ownerNode;
  35176. private _sceneRenderObserver;
  35177. /**
  35178. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35179. */
  35180. constructor();
  35181. /**
  35182. * The name of the behavior
  35183. */
  35184. readonly name: string;
  35185. /**
  35186. * Initializes the behavior
  35187. */
  35188. init(): void;
  35189. private _getCurrentDistance;
  35190. /**
  35191. * Attaches the scale behavior the passed in mesh
  35192. * @param ownerNode The mesh that will be scaled around once attached
  35193. */
  35194. attach(ownerNode: Mesh): void;
  35195. /**
  35196. * Detaches the behavior from the mesh
  35197. */
  35198. detach(): void;
  35199. }
  35200. }
  35201. declare module BABYLON {
  35202. /**
  35203. * 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
  35204. */
  35205. export class SixDofDragBehavior implements Behavior<Mesh> {
  35206. private static _virtualScene;
  35207. private _ownerNode;
  35208. private _sceneRenderObserver;
  35209. private _scene;
  35210. private _targetPosition;
  35211. private _virtualOriginMesh;
  35212. private _virtualDragMesh;
  35213. private _pointerObserver;
  35214. private _moving;
  35215. private _startingOrientation;
  35216. /**
  35217. * 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)
  35218. */
  35219. private zDragFactor;
  35220. /**
  35221. * If the object should rotate to face the drag origin
  35222. */
  35223. rotateDraggedObject: boolean;
  35224. /**
  35225. * If the behavior is currently in a dragging state
  35226. */
  35227. dragging: boolean;
  35228. /**
  35229. * 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)
  35230. */
  35231. dragDeltaRatio: number;
  35232. /**
  35233. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35234. */
  35235. currentDraggingPointerID: number;
  35236. /**
  35237. * If camera controls should be detached during the drag
  35238. */
  35239. detachCameraControls: boolean;
  35240. /**
  35241. * Fires each time a drag starts
  35242. */
  35243. onDragStartObservable: Observable<{}>;
  35244. /**
  35245. * Fires each time a drag ends (eg. mouse release after drag)
  35246. */
  35247. onDragEndObservable: Observable<{}>;
  35248. /**
  35249. * 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
  35250. */
  35251. constructor();
  35252. /**
  35253. * The name of the behavior
  35254. */
  35255. readonly name: string;
  35256. /**
  35257. * Initializes the behavior
  35258. */
  35259. init(): void;
  35260. /**
  35261. * Attaches the scale behavior the passed in mesh
  35262. * @param ownerNode The mesh that will be scaled around once attached
  35263. */
  35264. attach(ownerNode: Mesh): void;
  35265. /**
  35266. * Detaches the behavior from the mesh
  35267. */
  35268. detach(): void;
  35269. }
  35270. }
  35271. declare module BABYLON {
  35272. /**
  35273. * Class used to apply inverse kinematics to bones
  35274. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35275. */
  35276. export class BoneIKController {
  35277. private static _tmpVecs;
  35278. private static _tmpQuat;
  35279. private static _tmpMats;
  35280. /**
  35281. * Gets or sets the target mesh
  35282. */
  35283. targetMesh: AbstractMesh;
  35284. /** Gets or sets the mesh used as pole */
  35285. poleTargetMesh: AbstractMesh;
  35286. /**
  35287. * Gets or sets the bone used as pole
  35288. */
  35289. poleTargetBone: Nullable<Bone>;
  35290. /**
  35291. * Gets or sets the target position
  35292. */
  35293. targetPosition: Vector3;
  35294. /**
  35295. * Gets or sets the pole target position
  35296. */
  35297. poleTargetPosition: Vector3;
  35298. /**
  35299. * Gets or sets the pole target local offset
  35300. */
  35301. poleTargetLocalOffset: Vector3;
  35302. /**
  35303. * Gets or sets the pole angle
  35304. */
  35305. poleAngle: number;
  35306. /**
  35307. * Gets or sets the mesh associated with the controller
  35308. */
  35309. mesh: AbstractMesh;
  35310. /**
  35311. * 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)
  35312. */
  35313. slerpAmount: number;
  35314. private _bone1Quat;
  35315. private _bone1Mat;
  35316. private _bone2Ang;
  35317. private _bone1;
  35318. private _bone2;
  35319. private _bone1Length;
  35320. private _bone2Length;
  35321. private _maxAngle;
  35322. private _maxReach;
  35323. private _rightHandedSystem;
  35324. private _bendAxis;
  35325. private _slerping;
  35326. private _adjustRoll;
  35327. /**
  35328. * Gets or sets maximum allowed angle
  35329. */
  35330. maxAngle: number;
  35331. /**
  35332. * Creates a new BoneIKController
  35333. * @param mesh defines the mesh to control
  35334. * @param bone defines the bone to control
  35335. * @param options defines options to set up the controller
  35336. */
  35337. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35338. targetMesh?: AbstractMesh;
  35339. poleTargetMesh?: AbstractMesh;
  35340. poleTargetBone?: Bone;
  35341. poleTargetLocalOffset?: Vector3;
  35342. poleAngle?: number;
  35343. bendAxis?: Vector3;
  35344. maxAngle?: number;
  35345. slerpAmount?: number;
  35346. });
  35347. private _setMaxAngle;
  35348. /**
  35349. * Force the controller to update the bones
  35350. */
  35351. update(): void;
  35352. }
  35353. }
  35354. declare module BABYLON {
  35355. /**
  35356. * Class used to make a bone look toward a point in space
  35357. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35358. */
  35359. export class BoneLookController {
  35360. private static _tmpVecs;
  35361. private static _tmpQuat;
  35362. private static _tmpMats;
  35363. /**
  35364. * The target Vector3 that the bone will look at
  35365. */
  35366. target: Vector3;
  35367. /**
  35368. * The mesh that the bone is attached to
  35369. */
  35370. mesh: AbstractMesh;
  35371. /**
  35372. * The bone that will be looking to the target
  35373. */
  35374. bone: Bone;
  35375. /**
  35376. * The up axis of the coordinate system that is used when the bone is rotated
  35377. */
  35378. upAxis: Vector3;
  35379. /**
  35380. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35381. */
  35382. upAxisSpace: Space;
  35383. /**
  35384. * Used to make an adjustment to the yaw of the bone
  35385. */
  35386. adjustYaw: number;
  35387. /**
  35388. * Used to make an adjustment to the pitch of the bone
  35389. */
  35390. adjustPitch: number;
  35391. /**
  35392. * Used to make an adjustment to the roll of the bone
  35393. */
  35394. adjustRoll: number;
  35395. /**
  35396. * 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)
  35397. */
  35398. slerpAmount: number;
  35399. private _minYaw;
  35400. private _maxYaw;
  35401. private _minPitch;
  35402. private _maxPitch;
  35403. private _minYawSin;
  35404. private _minYawCos;
  35405. private _maxYawSin;
  35406. private _maxYawCos;
  35407. private _midYawConstraint;
  35408. private _minPitchTan;
  35409. private _maxPitchTan;
  35410. private _boneQuat;
  35411. private _slerping;
  35412. private _transformYawPitch;
  35413. private _transformYawPitchInv;
  35414. private _firstFrameSkipped;
  35415. private _yawRange;
  35416. private _fowardAxis;
  35417. /**
  35418. * Gets or sets the minimum yaw angle that the bone can look to
  35419. */
  35420. minYaw: number;
  35421. /**
  35422. * Gets or sets the maximum yaw angle that the bone can look to
  35423. */
  35424. maxYaw: number;
  35425. /**
  35426. * Gets or sets the minimum pitch angle that the bone can look to
  35427. */
  35428. minPitch: number;
  35429. /**
  35430. * Gets or sets the maximum pitch angle that the bone can look to
  35431. */
  35432. maxPitch: number;
  35433. /**
  35434. * Create a BoneLookController
  35435. * @param mesh the mesh that the bone belongs to
  35436. * @param bone the bone that will be looking to the target
  35437. * @param target the target Vector3 to look at
  35438. * @param options optional settings:
  35439. * * maxYaw: the maximum angle the bone will yaw to
  35440. * * minYaw: the minimum angle the bone will yaw to
  35441. * * maxPitch: the maximum angle the bone will pitch to
  35442. * * minPitch: the minimum angle the bone will yaw to
  35443. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35444. * * upAxis: the up axis of the coordinate system
  35445. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35446. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35447. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35448. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35449. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35450. * * adjustRoll: used to make an adjustment to the roll of the bone
  35451. **/
  35452. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35453. maxYaw?: number;
  35454. minYaw?: number;
  35455. maxPitch?: number;
  35456. minPitch?: number;
  35457. slerpAmount?: number;
  35458. upAxis?: Vector3;
  35459. upAxisSpace?: Space;
  35460. yawAxis?: Vector3;
  35461. pitchAxis?: Vector3;
  35462. adjustYaw?: number;
  35463. adjustPitch?: number;
  35464. adjustRoll?: number;
  35465. });
  35466. /**
  35467. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35468. */
  35469. update(): void;
  35470. private _getAngleDiff;
  35471. private _getAngleBetween;
  35472. private _isAngleBetween;
  35473. }
  35474. }
  35475. declare module BABYLON {
  35476. /**
  35477. * Manage the gamepad inputs to control an arc rotate camera.
  35478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35479. */
  35480. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35481. /**
  35482. * Defines the camera the input is attached to.
  35483. */
  35484. camera: ArcRotateCamera;
  35485. /**
  35486. * Defines the gamepad the input is gathering event from.
  35487. */
  35488. gamepad: Nullable<Gamepad>;
  35489. /**
  35490. * Defines the gamepad rotation sensiblity.
  35491. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35492. */
  35493. gamepadRotationSensibility: number;
  35494. /**
  35495. * Defines the gamepad move sensiblity.
  35496. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35497. */
  35498. gamepadMoveSensibility: number;
  35499. private _onGamepadConnectedObserver;
  35500. private _onGamepadDisconnectedObserver;
  35501. /**
  35502. * Attach the input controls to a specific dom element to get the input from.
  35503. * @param element Defines the element the controls should be listened from
  35504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35505. */
  35506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35507. /**
  35508. * Detach the current controls from the specified dom element.
  35509. * @param element Defines the element to stop listening the inputs from
  35510. */
  35511. detachControl(element: Nullable<HTMLElement>): void;
  35512. /**
  35513. * Update the current camera state depending on the inputs that have been used this frame.
  35514. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35515. */
  35516. checkInputs(): void;
  35517. /**
  35518. * Gets the class name of the current intput.
  35519. * @returns the class name
  35520. */
  35521. getClassName(): string;
  35522. /**
  35523. * Get the friendly name associated with the input class.
  35524. * @returns the input friendly name
  35525. */
  35526. getSimpleName(): string;
  35527. }
  35528. }
  35529. declare module BABYLON {
  35530. interface ArcRotateCameraInputsManager {
  35531. /**
  35532. * Add orientation input support to the input manager.
  35533. * @returns the current input manager
  35534. */
  35535. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35536. }
  35537. /**
  35538. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35540. */
  35541. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35542. /**
  35543. * Defines the camera the input is attached to.
  35544. */
  35545. camera: ArcRotateCamera;
  35546. /**
  35547. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35548. */
  35549. alphaCorrection: number;
  35550. /**
  35551. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35552. */
  35553. gammaCorrection: number;
  35554. private _alpha;
  35555. private _gamma;
  35556. private _dirty;
  35557. private _deviceOrientationHandler;
  35558. /**
  35559. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35560. */
  35561. constructor();
  35562. /**
  35563. * Attach the input controls to a specific dom element to get the input from.
  35564. * @param element Defines the element the controls should be listened from
  35565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35566. */
  35567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35568. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  35569. /**
  35570. * Update the current camera state depending on the inputs that have been used this frame.
  35571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35572. */
  35573. checkInputs(): void;
  35574. /**
  35575. * Detach the current controls from the specified dom element.
  35576. * @param element Defines the element to stop listening the inputs from
  35577. */
  35578. detachControl(element: Nullable<HTMLElement>): void;
  35579. /**
  35580. * Gets the class name of the current intput.
  35581. * @returns the class name
  35582. */
  35583. getClassName(): string;
  35584. /**
  35585. * Get the friendly name associated with the input class.
  35586. * @returns the input friendly name
  35587. */
  35588. getSimpleName(): string;
  35589. }
  35590. }
  35591. declare module BABYLON {
  35592. /**
  35593. * Listen to mouse events to control the camera.
  35594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35595. */
  35596. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35597. /**
  35598. * Defines the camera the input is attached to.
  35599. */
  35600. camera: FlyCamera;
  35601. /**
  35602. * Defines if touch is enabled. (Default is true.)
  35603. */
  35604. touchEnabled: boolean;
  35605. /**
  35606. * Defines the buttons associated with the input to handle camera rotation.
  35607. */
  35608. buttons: number[];
  35609. /**
  35610. * Assign buttons for Yaw control.
  35611. */
  35612. buttonsYaw: number[];
  35613. /**
  35614. * Assign buttons for Pitch control.
  35615. */
  35616. buttonsPitch: number[];
  35617. /**
  35618. * Assign buttons for Roll control.
  35619. */
  35620. buttonsRoll: number[];
  35621. /**
  35622. * Detect if any button is being pressed while mouse is moved.
  35623. * -1 = Mouse locked.
  35624. * 0 = Left button.
  35625. * 1 = Middle Button.
  35626. * 2 = Right Button.
  35627. */
  35628. activeButton: number;
  35629. /**
  35630. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35631. * Higher values reduce its sensitivity.
  35632. */
  35633. angularSensibility: number;
  35634. private _mousemoveCallback;
  35635. private _observer;
  35636. private _rollObserver;
  35637. private previousPosition;
  35638. private noPreventDefault;
  35639. private element;
  35640. /**
  35641. * Listen to mouse events to control the camera.
  35642. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35644. */
  35645. constructor(touchEnabled?: boolean);
  35646. /**
  35647. * Attach the mouse control to the HTML DOM element.
  35648. * @param element Defines the element that listens to the input events.
  35649. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35650. */
  35651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35652. /**
  35653. * Detach the current controls from the specified dom element.
  35654. * @param element Defines the element to stop listening the inputs from
  35655. */
  35656. detachControl(element: Nullable<HTMLElement>): void;
  35657. /**
  35658. * Gets the class name of the current input.
  35659. * @returns the class name.
  35660. */
  35661. getClassName(): string;
  35662. /**
  35663. * Get the friendly name associated with the input class.
  35664. * @returns the input's friendly name.
  35665. */
  35666. getSimpleName(): string;
  35667. private _pointerInput;
  35668. private _onMouseMove;
  35669. /**
  35670. * Rotate camera by mouse offset.
  35671. */
  35672. private rotateCamera;
  35673. }
  35674. }
  35675. declare module BABYLON {
  35676. /**
  35677. * Default Inputs manager for the FlyCamera.
  35678. * It groups all the default supported inputs for ease of use.
  35679. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35680. */
  35681. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35682. /**
  35683. * Instantiates a new FlyCameraInputsManager.
  35684. * @param camera Defines the camera the inputs belong to.
  35685. */
  35686. constructor(camera: FlyCamera);
  35687. /**
  35688. * Add keyboard input support to the input manager.
  35689. * @returns the new FlyCameraKeyboardMoveInput().
  35690. */
  35691. addKeyboard(): FlyCameraInputsManager;
  35692. /**
  35693. * Add mouse input support to the input manager.
  35694. * @param touchEnabled Enable touch screen support.
  35695. * @returns the new FlyCameraMouseInput().
  35696. */
  35697. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35698. }
  35699. }
  35700. declare module BABYLON {
  35701. /**
  35702. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35703. * such as in a 3D Space Shooter or a Flight Simulator.
  35704. */
  35705. export class FlyCamera extends TargetCamera {
  35706. /**
  35707. * Define the collision ellipsoid of the camera.
  35708. * This is helpful for simulating a camera body, like a player's body.
  35709. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35710. */
  35711. ellipsoid: Vector3;
  35712. /**
  35713. * Define an offset for the position of the ellipsoid around the camera.
  35714. * This can be helpful if the camera is attached away from the player's body center,
  35715. * such as at its head.
  35716. */
  35717. ellipsoidOffset: Vector3;
  35718. /**
  35719. * Enable or disable collisions of the camera with the rest of the scene objects.
  35720. */
  35721. checkCollisions: boolean;
  35722. /**
  35723. * Enable or disable gravity on the camera.
  35724. */
  35725. applyGravity: boolean;
  35726. /**
  35727. * Define the current direction the camera is moving to.
  35728. */
  35729. cameraDirection: Vector3;
  35730. /**
  35731. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35732. * This overrides and empties cameraRotation.
  35733. */
  35734. rotationQuaternion: Quaternion;
  35735. /**
  35736. * Track Roll to maintain the wanted Rolling when looking around.
  35737. */ trackRoll: number;
  35738. /**
  35739. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35740. */
  35741. rollCorrect: number;
  35742. /**
  35743. * Mimic a banked turn, Rolling the camera when Yawing.
  35744. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35745. */
  35746. bankedTurn: boolean;
  35747. /**
  35748. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35749. */
  35750. bankedTurnLimit: number;
  35751. /**
  35752. * Value of 0 disables the banked Roll.
  35753. * Value of 1 is equal to the Yaw angle in radians.
  35754. */
  35755. bankedTurnMultiplier: number;
  35756. /**
  35757. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35758. */
  35759. inputs: FlyCameraInputsManager;
  35760. /**
  35761. * Gets the input sensibility for mouse input.
  35762. * Higher values reduce sensitivity.
  35763. */
  35764. /**
  35765. * Sets the input sensibility for a mouse input.
  35766. * Higher values reduce sensitivity.
  35767. */
  35768. angularSensibility: number;
  35769. /**
  35770. * Get the keys for camera movement forward.
  35771. */
  35772. /**
  35773. * Set the keys for camera movement forward.
  35774. */
  35775. keysForward: number[];
  35776. /**
  35777. * Get the keys for camera movement backward.
  35778. */
  35779. keysBackward: number[];
  35780. /**
  35781. * Get the keys for camera movement up.
  35782. */
  35783. /**
  35784. * Set the keys for camera movement up.
  35785. */
  35786. keysUp: number[];
  35787. /**
  35788. * Get the keys for camera movement down.
  35789. */
  35790. /**
  35791. * Set the keys for camera movement down.
  35792. */
  35793. keysDown: number[];
  35794. /**
  35795. * Get the keys for camera movement left.
  35796. */
  35797. /**
  35798. * Set the keys for camera movement left.
  35799. */
  35800. keysLeft: number[];
  35801. /**
  35802. * Set the keys for camera movement right.
  35803. */
  35804. /**
  35805. * Set the keys for camera movement right.
  35806. */
  35807. keysRight: number[];
  35808. /**
  35809. * Event raised when the camera collides with a mesh in the scene.
  35810. */
  35811. onCollide: (collidedMesh: AbstractMesh) => void;
  35812. private _collider;
  35813. private _needMoveForGravity;
  35814. private _oldPosition;
  35815. private _diffPosition;
  35816. private _newPosition;
  35817. /** @hidden */ localDirection: Vector3;
  35818. /** @hidden */ transformedDirection: Vector3;
  35819. /**
  35820. * Instantiates a FlyCamera.
  35821. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35822. * such as in a 3D Space Shooter or a Flight Simulator.
  35823. * @param name Define the name of the camera in the scene.
  35824. * @param position Define the starting position of the camera in the scene.
  35825. * @param scene Define the scene the camera belongs to.
  35826. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35827. */
  35828. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35829. /**
  35830. * Attach a control to the HTML DOM element.
  35831. * @param element Defines the element that listens to the input events.
  35832. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35833. */
  35834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35835. /**
  35836. * Detach a control from the HTML DOM element.
  35837. * The camera will stop reacting to that input.
  35838. * @param element Defines the element that listens to the input events.
  35839. */
  35840. detachControl(element: HTMLElement): void;
  35841. private _collisionMask;
  35842. /**
  35843. * Get the mask that the camera ignores in collision events.
  35844. */
  35845. /**
  35846. * Set the mask that the camera ignores in collision events.
  35847. */
  35848. collisionMask: number;
  35849. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  35850. /** @hidden */
  35851. private _onCollisionPositionChange;
  35852. /** @hidden */ checkInputs(): void;
  35853. /** @hidden */ decideIfNeedsToMove(): boolean;
  35854. /** @hidden */ updatePosition(): void;
  35855. /**
  35856. * Restore the Roll to its target value at the rate specified.
  35857. * @param rate - Higher means slower restoring.
  35858. * @hidden
  35859. */
  35860. restoreRoll(rate: number): void;
  35861. /**
  35862. * Destroy the camera and release the current resources held by it.
  35863. */
  35864. dispose(): void;
  35865. /**
  35866. * Get the current object class name.
  35867. * @returns the class name.
  35868. */
  35869. getClassName(): string;
  35870. }
  35871. }
  35872. declare module BABYLON {
  35873. /**
  35874. * Listen to keyboard events to control the camera.
  35875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35876. */
  35877. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35878. /**
  35879. * Defines the camera the input is attached to.
  35880. */
  35881. camera: FlyCamera;
  35882. /**
  35883. * The list of keyboard keys used to control the forward move of the camera.
  35884. */
  35885. keysForward: number[];
  35886. /**
  35887. * The list of keyboard keys used to control the backward move of the camera.
  35888. */
  35889. keysBackward: number[];
  35890. /**
  35891. * The list of keyboard keys used to control the forward move of the camera.
  35892. */
  35893. keysUp: number[];
  35894. /**
  35895. * The list of keyboard keys used to control the backward move of the camera.
  35896. */
  35897. keysDown: number[];
  35898. /**
  35899. * The list of keyboard keys used to control the right strafe move of the camera.
  35900. */
  35901. keysRight: number[];
  35902. /**
  35903. * The list of keyboard keys used to control the left strafe move of the camera.
  35904. */
  35905. keysLeft: number[];
  35906. private _keys;
  35907. private _onCanvasBlurObserver;
  35908. private _onKeyboardObserver;
  35909. private _engine;
  35910. private _scene;
  35911. /**
  35912. * Attach the input controls to a specific dom element to get the input from.
  35913. * @param element Defines the element the controls should be listened from
  35914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35915. */
  35916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35917. /**
  35918. * Detach the current controls from the specified dom element.
  35919. * @param element Defines the element to stop listening the inputs from
  35920. */
  35921. detachControl(element: Nullable<HTMLElement>): void;
  35922. /**
  35923. * Gets the class name of the current intput.
  35924. * @returns the class name
  35925. */
  35926. getClassName(): string;
  35927. /** @hidden */ onLostFocus(e: FocusEvent): void;
  35928. /**
  35929. * Get the friendly name associated with the input class.
  35930. * @returns the input friendly name
  35931. */
  35932. getSimpleName(): string;
  35933. /**
  35934. * Update the current camera state depending on the inputs that have been used this frame.
  35935. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35936. */
  35937. checkInputs(): void;
  35938. }
  35939. }
  35940. declare module BABYLON {
  35941. /**
  35942. * Manage the mouse wheel inputs to control a follow camera.
  35943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35944. */
  35945. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35946. /**
  35947. * Defines the camera the input is attached to.
  35948. */
  35949. camera: FollowCamera;
  35950. /**
  35951. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  35952. */
  35953. axisControlRadius: boolean;
  35954. /**
  35955. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  35956. */
  35957. axisControlHeight: boolean;
  35958. /**
  35959. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  35960. */
  35961. axisControlRotation: boolean;
  35962. /**
  35963. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35964. * relation to mouseWheel events.
  35965. */
  35966. wheelPrecision: number;
  35967. /**
  35968. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35969. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35970. */
  35971. wheelDeltaPercentage: number;
  35972. private _wheel;
  35973. private _observer;
  35974. /**
  35975. * Attach the input controls to a specific dom element to get the input from.
  35976. * @param element Defines the element the controls should be listened from
  35977. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35978. */
  35979. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35980. /**
  35981. * Detach the current controls from the specified dom element.
  35982. * @param element Defines the element to stop listening the inputs from
  35983. */
  35984. detachControl(element: Nullable<HTMLElement>): void;
  35985. /**
  35986. * Gets the class name of the current intput.
  35987. * @returns the class name
  35988. */
  35989. getClassName(): string;
  35990. /**
  35991. * Get the friendly name associated with the input class.
  35992. * @returns the input friendly name
  35993. */
  35994. getSimpleName(): string;
  35995. }
  35996. }
  35997. declare module BABYLON {
  35998. /**
  35999. * Manage the pointers inputs to control an follow camera.
  36000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36001. */
  36002. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36003. /**
  36004. * Defines the camera the input is attached to.
  36005. */
  36006. camera: FollowCamera;
  36007. /**
  36008. * Gets the class name of the current input.
  36009. * @returns the class name
  36010. */
  36011. getClassName(): string;
  36012. /**
  36013. * Defines the pointer angular sensibility along the X axis or how fast is
  36014. * the camera rotating.
  36015. * A negative number will reverse the axis direction.
  36016. */
  36017. angularSensibilityX: number;
  36018. /**
  36019. * Defines the pointer angular sensibility along the Y axis or how fast is
  36020. * the camera rotating.
  36021. * A negative number will reverse the axis direction.
  36022. */
  36023. angularSensibilityY: number;
  36024. /**
  36025. * Defines the pointer pinch precision or how fast is the camera zooming.
  36026. * A negative number will reverse the axis direction.
  36027. */
  36028. pinchPrecision: number;
  36029. /**
  36030. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36031. * from 0.
  36032. * It defines the percentage of current camera.radius to use as delta when
  36033. * pinch zoom is used.
  36034. */
  36035. pinchDeltaPercentage: number;
  36036. /**
  36037. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36038. */
  36039. axisXControlRadius: boolean;
  36040. /**
  36041. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36042. */
  36043. axisXControlHeight: boolean;
  36044. /**
  36045. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36046. */
  36047. axisXControlRotation: boolean;
  36048. /**
  36049. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36050. */
  36051. axisYControlRadius: boolean;
  36052. /**
  36053. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36054. */
  36055. axisYControlHeight: boolean;
  36056. /**
  36057. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36058. */
  36059. axisYControlRotation: boolean;
  36060. /**
  36061. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36062. */
  36063. axisPinchControlRadius: boolean;
  36064. /**
  36065. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36066. */
  36067. axisPinchControlHeight: boolean;
  36068. /**
  36069. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36070. */
  36071. axisPinchControlRotation: boolean;
  36072. /**
  36073. * Log error messages if basic misconfiguration has occurred.
  36074. */
  36075. warningEnable: boolean;
  36076. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36077. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36078. private _warningCounter;
  36079. private _warning;
  36080. }
  36081. }
  36082. declare module BABYLON {
  36083. /**
  36084. * Default Inputs manager for the FollowCamera.
  36085. * It groups all the default supported inputs for ease of use.
  36086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36087. */
  36088. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36089. /**
  36090. * Instantiates a new FollowCameraInputsManager.
  36091. * @param camera Defines the camera the inputs belong to
  36092. */
  36093. constructor(camera: FollowCamera);
  36094. /**
  36095. * Add keyboard input support to the input manager.
  36096. * @returns the current input manager
  36097. */
  36098. addKeyboard(): FollowCameraInputsManager;
  36099. /**
  36100. * Add mouse wheel input support to the input manager.
  36101. * @returns the current input manager
  36102. */
  36103. addMouseWheel(): FollowCameraInputsManager;
  36104. /**
  36105. * Add pointers input support to the input manager.
  36106. * @returns the current input manager
  36107. */
  36108. addPointers(): FollowCameraInputsManager;
  36109. /**
  36110. * Add orientation input support to the input manager.
  36111. * @returns the current input manager
  36112. */
  36113. addVRDeviceOrientation(): FollowCameraInputsManager;
  36114. }
  36115. }
  36116. declare module BABYLON {
  36117. /**
  36118. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36119. * an arc rotate version arcFollowCamera are available.
  36120. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36121. */
  36122. export class FollowCamera extends TargetCamera {
  36123. /**
  36124. * Distance the follow camera should follow an object at
  36125. */
  36126. radius: number;
  36127. /**
  36128. * Minimum allowed distance of the camera to the axis of rotation
  36129. * (The camera can not get closer).
  36130. * This can help limiting how the Camera is able to move in the scene.
  36131. */
  36132. lowerRadiusLimit: Nullable<number>;
  36133. /**
  36134. * Maximum allowed distance of the camera to the axis of rotation
  36135. * (The camera can not get further).
  36136. * This can help limiting how the Camera is able to move in the scene.
  36137. */
  36138. upperRadiusLimit: Nullable<number>;
  36139. /**
  36140. * Define a rotation offset between the camera and the object it follows
  36141. */
  36142. rotationOffset: number;
  36143. /**
  36144. * Minimum allowed angle to camera position relative to target object.
  36145. * This can help limiting how the Camera is able to move in the scene.
  36146. */
  36147. lowerRotationOffsetLimit: Nullable<number>;
  36148. /**
  36149. * Maximum allowed angle to camera position relative to target object.
  36150. * This can help limiting how the Camera is able to move in the scene.
  36151. */
  36152. upperRotationOffsetLimit: Nullable<number>;
  36153. /**
  36154. * Define a height offset between the camera and the object it follows.
  36155. * It can help following an object from the top (like a car chaing a plane)
  36156. */
  36157. heightOffset: number;
  36158. /**
  36159. * Minimum allowed height of camera position relative to target object.
  36160. * This can help limiting how the Camera is able to move in the scene.
  36161. */
  36162. lowerHeightOffsetLimit: Nullable<number>;
  36163. /**
  36164. * Maximum allowed height of camera position relative to target object.
  36165. * This can help limiting how the Camera is able to move in the scene.
  36166. */
  36167. upperHeightOffsetLimit: Nullable<number>;
  36168. /**
  36169. * Define how fast the camera can accelerate to follow it s target.
  36170. */
  36171. cameraAcceleration: number;
  36172. /**
  36173. * Define the speed limit of the camera following an object.
  36174. */
  36175. maxCameraSpeed: number;
  36176. /**
  36177. * Define the target of the camera.
  36178. */
  36179. lockedTarget: Nullable<AbstractMesh>;
  36180. /**
  36181. * Defines the input associated with the camera.
  36182. */
  36183. inputs: FollowCameraInputsManager;
  36184. /**
  36185. * Instantiates the follow camera.
  36186. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36187. * @param name Define the name of the camera in the scene
  36188. * @param position Define the position of the camera
  36189. * @param scene Define the scene the camera belong to
  36190. * @param lockedTarget Define the target of the camera
  36191. */
  36192. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36193. private _follow;
  36194. /**
  36195. * Attached controls to the current camera.
  36196. * @param element Defines the element the controls should be listened from
  36197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36198. */
  36199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36200. /**
  36201. * Detach the current controls from the camera.
  36202. * The camera will stop reacting to inputs.
  36203. * @param element Defines the element to stop listening the inputs from
  36204. */
  36205. detachControl(element: HTMLElement): void;
  36206. /** @hidden */ checkInputs(): void;
  36207. private _checkLimits;
  36208. /**
  36209. * Gets the camera class name.
  36210. * @returns the class name
  36211. */
  36212. getClassName(): string;
  36213. }
  36214. /**
  36215. * Arc Rotate version of the follow camera.
  36216. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36217. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36218. */
  36219. export class ArcFollowCamera extends TargetCamera {
  36220. /** The longitudinal angle of the camera */
  36221. alpha: number;
  36222. /** The latitudinal angle of the camera */
  36223. beta: number;
  36224. /** The radius of the camera from its target */
  36225. radius: number;
  36226. /** Define the camera target (the messh it should follow) */
  36227. target: Nullable<AbstractMesh>;
  36228. private _cartesianCoordinates;
  36229. /**
  36230. * Instantiates a new ArcFollowCamera
  36231. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36232. * @param name Define the name of the camera
  36233. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36234. * @param beta Define the rotation angle of the camera around the elevation axis
  36235. * @param radius Define the radius of the camera from its target point
  36236. * @param target Define the target of the camera
  36237. * @param scene Define the scene the camera belongs to
  36238. */
  36239. constructor(name: string,
  36240. /** The longitudinal angle of the camera */
  36241. alpha: number,
  36242. /** The latitudinal angle of the camera */
  36243. beta: number,
  36244. /** The radius of the camera from its target */
  36245. radius: number,
  36246. /** Define the camera target (the messh it should follow) */
  36247. target: Nullable<AbstractMesh>, scene: Scene);
  36248. private _follow;
  36249. /** @hidden */ checkInputs(): void;
  36250. /**
  36251. * Returns the class name of the object.
  36252. * It is mostly used internally for serialization purposes.
  36253. */
  36254. getClassName(): string;
  36255. }
  36256. }
  36257. declare module BABYLON {
  36258. /**
  36259. * Manage the keyboard inputs to control the movement of a follow camera.
  36260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36261. */
  36262. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36263. /**
  36264. * Defines the camera the input is attached to.
  36265. */
  36266. camera: FollowCamera;
  36267. /**
  36268. * Defines the list of key codes associated with the up action (increase heightOffset)
  36269. */
  36270. keysHeightOffsetIncr: number[];
  36271. /**
  36272. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36273. */
  36274. keysHeightOffsetDecr: number[];
  36275. /**
  36276. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36277. */
  36278. keysHeightOffsetModifierAlt: boolean;
  36279. /**
  36280. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36281. */
  36282. keysHeightOffsetModifierCtrl: boolean;
  36283. /**
  36284. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36285. */
  36286. keysHeightOffsetModifierShift: boolean;
  36287. /**
  36288. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36289. */
  36290. keysRotationOffsetIncr: number[];
  36291. /**
  36292. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36293. */
  36294. keysRotationOffsetDecr: number[];
  36295. /**
  36296. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36297. */
  36298. keysRotationOffsetModifierAlt: boolean;
  36299. /**
  36300. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36301. */
  36302. keysRotationOffsetModifierCtrl: boolean;
  36303. /**
  36304. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36305. */
  36306. keysRotationOffsetModifierShift: boolean;
  36307. /**
  36308. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36309. */
  36310. keysRadiusIncr: number[];
  36311. /**
  36312. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36313. */
  36314. keysRadiusDecr: number[];
  36315. /**
  36316. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36317. */
  36318. keysRadiusModifierAlt: boolean;
  36319. /**
  36320. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36321. */
  36322. keysRadiusModifierCtrl: boolean;
  36323. /**
  36324. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36325. */
  36326. keysRadiusModifierShift: boolean;
  36327. /**
  36328. * Defines the rate of change of heightOffset.
  36329. */
  36330. heightSensibility: number;
  36331. /**
  36332. * Defines the rate of change of rotationOffset.
  36333. */
  36334. rotationSensibility: number;
  36335. /**
  36336. * Defines the rate of change of radius.
  36337. */
  36338. radiusSensibility: number;
  36339. private _keys;
  36340. private _ctrlPressed;
  36341. private _altPressed;
  36342. private _shiftPressed;
  36343. private _onCanvasBlurObserver;
  36344. private _onKeyboardObserver;
  36345. private _engine;
  36346. private _scene;
  36347. /**
  36348. * Attach the input controls to a specific dom element to get the input from.
  36349. * @param element Defines the element the controls should be listened from
  36350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36351. */
  36352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36353. /**
  36354. * Detach the current controls from the specified dom element.
  36355. * @param element Defines the element to stop listening the inputs from
  36356. */
  36357. detachControl(element: Nullable<HTMLElement>): void;
  36358. /**
  36359. * Update the current camera state depending on the inputs that have been used this frame.
  36360. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36361. */
  36362. checkInputs(): void;
  36363. /**
  36364. * Gets the class name of the current input.
  36365. * @returns the class name
  36366. */
  36367. getClassName(): string;
  36368. /**
  36369. * Get the friendly name associated with the input class.
  36370. * @returns the input friendly name
  36371. */
  36372. getSimpleName(): string;
  36373. /**
  36374. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36375. * allow modification of the heightOffset value.
  36376. */
  36377. private _modifierHeightOffset;
  36378. /**
  36379. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36380. * allow modification of the rotationOffset value.
  36381. */
  36382. private _modifierRotationOffset;
  36383. /**
  36384. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36385. * allow modification of the radius value.
  36386. */
  36387. private _modifierRadius;
  36388. }
  36389. }
  36390. declare module BABYLON {
  36391. interface FreeCameraInputsManager {
  36392. /**
  36393. * @hidden
  36394. */ deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36395. /**
  36396. * Add orientation input support to the input manager.
  36397. * @returns the current input manager
  36398. */
  36399. addDeviceOrientation(): FreeCameraInputsManager;
  36400. }
  36401. /**
  36402. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36403. * Screen rotation is taken into account.
  36404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36405. */
  36406. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36407. private _camera;
  36408. private _screenOrientationAngle;
  36409. private _constantTranform;
  36410. private _screenQuaternion;
  36411. private _alpha;
  36412. private _beta;
  36413. private _gamma;
  36414. /**
  36415. * @hidden
  36416. */ onDeviceOrientationChangedObservable: Observable<void>;
  36417. /**
  36418. * Instantiates a new input
  36419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36420. */
  36421. constructor();
  36422. /**
  36423. * Define the camera controlled by the input.
  36424. */
  36425. camera: FreeCamera;
  36426. /**
  36427. * Attach the input controls to a specific dom element to get the input from.
  36428. * @param element Defines the element the controls should be listened from
  36429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36430. */
  36431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36432. private _orientationChanged;
  36433. private _deviceOrientation;
  36434. /**
  36435. * Detach the current controls from the specified dom element.
  36436. * @param element Defines the element to stop listening the inputs from
  36437. */
  36438. detachControl(element: Nullable<HTMLElement>): void;
  36439. /**
  36440. * Update the current camera state depending on the inputs that have been used this frame.
  36441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36442. */
  36443. checkInputs(): void;
  36444. /**
  36445. * Gets the class name of the current intput.
  36446. * @returns the class name
  36447. */
  36448. getClassName(): string;
  36449. /**
  36450. * Get the friendly name associated with the input class.
  36451. * @returns the input friendly name
  36452. */
  36453. getSimpleName(): string;
  36454. }
  36455. }
  36456. declare module BABYLON {
  36457. /**
  36458. * Manage the gamepad inputs to control a free camera.
  36459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36460. */
  36461. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36462. /**
  36463. * Define the camera the input is attached to.
  36464. */
  36465. camera: FreeCamera;
  36466. /**
  36467. * Define the Gamepad controlling the input
  36468. */
  36469. gamepad: Nullable<Gamepad>;
  36470. /**
  36471. * Defines the gamepad rotation sensiblity.
  36472. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36473. */
  36474. gamepadAngularSensibility: number;
  36475. /**
  36476. * Defines the gamepad move sensiblity.
  36477. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36478. */
  36479. gamepadMoveSensibility: number;
  36480. private _onGamepadConnectedObserver;
  36481. private _onGamepadDisconnectedObserver;
  36482. private _cameraTransform;
  36483. private _deltaTransform;
  36484. private _vector3;
  36485. private _vector2;
  36486. /**
  36487. * Attach the input controls to a specific dom element to get the input from.
  36488. * @param element Defines the element the controls should be listened from
  36489. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36490. */
  36491. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36492. /**
  36493. * Detach the current controls from the specified dom element.
  36494. * @param element Defines the element to stop listening the inputs from
  36495. */
  36496. detachControl(element: Nullable<HTMLElement>): 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. * Gets the class name of the current intput.
  36504. * @returns the class name
  36505. */
  36506. getClassName(): string;
  36507. /**
  36508. * Get the friendly name associated with the input class.
  36509. * @returns the input friendly name
  36510. */
  36511. getSimpleName(): string;
  36512. }
  36513. }
  36514. declare module BABYLON {
  36515. /**
  36516. * Defines the potential axis of a Joystick
  36517. */
  36518. export enum JoystickAxis {
  36519. /** X axis */
  36520. X = 0,
  36521. /** Y axis */
  36522. Y = 1,
  36523. /** Z axis */
  36524. Z = 2
  36525. }
  36526. /**
  36527. * Class used to define virtual joystick (used in touch mode)
  36528. */
  36529. export class VirtualJoystick {
  36530. /**
  36531. * Gets or sets a boolean indicating that left and right values must be inverted
  36532. */
  36533. reverseLeftRight: boolean;
  36534. /**
  36535. * Gets or sets a boolean indicating that up and down values must be inverted
  36536. */
  36537. reverseUpDown: boolean;
  36538. /**
  36539. * Gets the offset value for the position (ie. the change of the position value)
  36540. */
  36541. deltaPosition: Vector3;
  36542. /**
  36543. * Gets a boolean indicating if the virtual joystick was pressed
  36544. */
  36545. pressed: boolean;
  36546. /**
  36547. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36548. */
  36549. static Canvas: Nullable<HTMLCanvasElement>;
  36550. private static _globalJoystickIndex;
  36551. private static vjCanvasContext;
  36552. private static vjCanvasWidth;
  36553. private static vjCanvasHeight;
  36554. private static halfWidth;
  36555. private _action;
  36556. private _axisTargetedByLeftAndRight;
  36557. private _axisTargetedByUpAndDown;
  36558. private _joystickSensibility;
  36559. private _inversedSensibility;
  36560. private _joystickPointerID;
  36561. private _joystickColor;
  36562. private _joystickPointerPos;
  36563. private _joystickPreviousPointerPos;
  36564. private _joystickPointerStartPos;
  36565. private _deltaJoystickVector;
  36566. private _leftJoystick;
  36567. private _touches;
  36568. private _onPointerDownHandlerRef;
  36569. private _onPointerMoveHandlerRef;
  36570. private _onPointerUpHandlerRef;
  36571. private _onResize;
  36572. /**
  36573. * Creates a new virtual joystick
  36574. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36575. */
  36576. constructor(leftJoystick?: boolean);
  36577. /**
  36578. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36579. * @param newJoystickSensibility defines the new sensibility
  36580. */
  36581. setJoystickSensibility(newJoystickSensibility: number): void;
  36582. private _onPointerDown;
  36583. private _onPointerMove;
  36584. private _onPointerUp;
  36585. /**
  36586. * Change the color of the virtual joystick
  36587. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36588. */
  36589. setJoystickColor(newColor: string): void;
  36590. /**
  36591. * Defines a callback to call when the joystick is touched
  36592. * @param action defines the callback
  36593. */
  36594. setActionOnTouch(action: () => any): void;
  36595. /**
  36596. * Defines which axis you'd like to control for left & right
  36597. * @param axis defines the axis to use
  36598. */
  36599. setAxisForLeftRight(axis: JoystickAxis): void;
  36600. /**
  36601. * Defines which axis you'd like to control for up & down
  36602. * @param axis defines the axis to use
  36603. */
  36604. setAxisForUpDown(axis: JoystickAxis): void;
  36605. private _drawVirtualJoystick;
  36606. /**
  36607. * Release internal HTML canvas
  36608. */
  36609. releaseCanvas(): void;
  36610. }
  36611. }
  36612. declare module BABYLON {
  36613. interface FreeCameraInputsManager {
  36614. /**
  36615. * Add virtual joystick input support to the input manager.
  36616. * @returns the current input manager
  36617. */
  36618. addVirtualJoystick(): FreeCameraInputsManager;
  36619. }
  36620. /**
  36621. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36623. */
  36624. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36625. /**
  36626. * Defines the camera the input is attached to.
  36627. */
  36628. camera: FreeCamera;
  36629. private _leftjoystick;
  36630. private _rightjoystick;
  36631. /**
  36632. * Gets the left stick of the virtual joystick.
  36633. * @returns The virtual Joystick
  36634. */
  36635. getLeftJoystick(): VirtualJoystick;
  36636. /**
  36637. * Gets the right stick of the virtual joystick.
  36638. * @returns The virtual Joystick
  36639. */
  36640. getRightJoystick(): VirtualJoystick;
  36641. /**
  36642. * Update the current camera state depending on the inputs that have been used this frame.
  36643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36644. */
  36645. checkInputs(): void;
  36646. /**
  36647. * Attach the input controls to a specific dom element to get the input from.
  36648. * @param element Defines the element the controls should be listened from
  36649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36650. */
  36651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36652. /**
  36653. * Detach the current controls from the specified dom element.
  36654. * @param element Defines the element to stop listening the inputs from
  36655. */
  36656. detachControl(element: Nullable<HTMLElement>): void;
  36657. /**
  36658. * Gets the class name of the current intput.
  36659. * @returns the class name
  36660. */
  36661. getClassName(): string;
  36662. /**
  36663. * Get the friendly name associated with the input class.
  36664. * @returns the input friendly name
  36665. */
  36666. getSimpleName(): string;
  36667. }
  36668. }
  36669. declare module BABYLON {
  36670. /**
  36671. * This represents a FPS type of camera controlled by touch.
  36672. * This is like a universal camera minus the Gamepad controls.
  36673. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36674. */
  36675. export class TouchCamera extends FreeCamera {
  36676. /**
  36677. * Defines the touch sensibility for rotation.
  36678. * The higher the faster.
  36679. */
  36680. touchAngularSensibility: number;
  36681. /**
  36682. * Defines the touch sensibility for move.
  36683. * The higher the faster.
  36684. */
  36685. touchMoveSensibility: number;
  36686. /**
  36687. * Instantiates a new touch camera.
  36688. * This represents a FPS type of camera controlled by touch.
  36689. * This is like a universal camera minus the Gamepad controls.
  36690. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36691. * @param name Define the name of the camera in the scene
  36692. * @param position Define the start position of the camera in the scene
  36693. * @param scene Define the scene the camera belongs to
  36694. */
  36695. constructor(name: string, position: Vector3, scene: Scene);
  36696. /**
  36697. * Gets the current object class name.
  36698. * @return the class name
  36699. */
  36700. getClassName(): string;
  36701. /** @hidden */ setupInputs(): void;
  36702. }
  36703. }
  36704. declare module BABYLON {
  36705. /**
  36706. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36707. * being tilted forward or back and left or right.
  36708. */
  36709. export class DeviceOrientationCamera extends FreeCamera {
  36710. private _initialQuaternion;
  36711. private _quaternionCache;
  36712. private _tmpDragQuaternion;
  36713. /**
  36714. * Creates a new device orientation camera
  36715. * @param name The name of the camera
  36716. * @param position The start position camera
  36717. * @param scene The scene the camera belongs to
  36718. */
  36719. constructor(name: string, position: Vector3, scene: Scene);
  36720. /**
  36721. * @hidden
  36722. * Disabled pointer input on first orientation sensor update (Default: true)
  36723. */ disablePointerInputWhenUsingDeviceOrientation: boolean;
  36724. private _dragFactor;
  36725. /**
  36726. * Enabled turning on the y axis when the orientation sensor is active
  36727. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  36728. */
  36729. enableHorizontalDragging(dragFactor?: number): void;
  36730. /**
  36731. * Gets the current instance class name ("DeviceOrientationCamera").
  36732. * This helps avoiding instanceof at run time.
  36733. * @returns the class name
  36734. */
  36735. getClassName(): string;
  36736. /**
  36737. * @hidden
  36738. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36739. */ checkInputs(): void;
  36740. /**
  36741. * Reset the camera to its default orientation on the specified axis only.
  36742. * @param axis The axis to reset
  36743. */
  36744. resetToCurrentRotation(axis?: Axis): void;
  36745. }
  36746. }
  36747. declare module BABYLON {
  36748. /**
  36749. * 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,
  36750. * which still works and will still be found in many Playgrounds.
  36751. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36752. */
  36753. export class UniversalCamera extends TouchCamera {
  36754. /**
  36755. * Defines the gamepad rotation sensiblity.
  36756. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36757. */
  36758. gamepadAngularSensibility: number;
  36759. /**
  36760. * Defines the gamepad move sensiblity.
  36761. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36762. */
  36763. gamepadMoveSensibility: number;
  36764. /**
  36765. * 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,
  36766. * which still works and will still be found in many Playgrounds.
  36767. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36768. * @param name Define the name of the camera in the scene
  36769. * @param position Define the start position of the camera in the scene
  36770. * @param scene Define the scene the camera belongs to
  36771. */
  36772. constructor(name: string, position: Vector3, scene: Scene);
  36773. /**
  36774. * Gets the current object class name.
  36775. * @return the class name
  36776. */
  36777. getClassName(): string;
  36778. }
  36779. }
  36780. declare module BABYLON {
  36781. /**
  36782. * This represents a FPS type of camera. This is only here for back compat purpose.
  36783. * Please use the UniversalCamera instead as both are identical.
  36784. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36785. */
  36786. export class GamepadCamera extends UniversalCamera {
  36787. /**
  36788. * Instantiates a new Gamepad Camera
  36789. * This represents a FPS type of camera. This is only here for back compat purpose.
  36790. * Please use the UniversalCamera instead as both are identical.
  36791. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36792. * @param name Define the name of the camera in the scene
  36793. * @param position Define the start position of the camera in the scene
  36794. * @param scene Define the scene the camera belongs to
  36795. */
  36796. constructor(name: string, position: Vector3, scene: Scene);
  36797. /**
  36798. * Gets the current object class name.
  36799. * @return the class name
  36800. */
  36801. getClassName(): string;
  36802. }
  36803. }
  36804. declare module BABYLON {
  36805. /** @hidden */
  36806. export var passPixelShader: {
  36807. name: string;
  36808. shader: string;
  36809. };
  36810. }
  36811. declare module BABYLON {
  36812. /** @hidden */
  36813. export var passCubePixelShader: {
  36814. name: string;
  36815. shader: string;
  36816. };
  36817. }
  36818. declare module BABYLON {
  36819. /**
  36820. * PassPostProcess which produces an output the same as it's input
  36821. */
  36822. export class PassPostProcess extends PostProcess {
  36823. /**
  36824. * Creates the PassPostProcess
  36825. * @param name The name of the effect.
  36826. * @param options The required width/height ratio to downsize to before computing the render pass.
  36827. * @param camera The camera to apply the render pass to.
  36828. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36829. * @param engine The engine which the post process will be applied. (default: current engine)
  36830. * @param reusable If the post process can be reused on the same frame. (default: false)
  36831. * @param textureType The type of texture to be used when performing the post processing.
  36832. * @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)
  36833. */
  36834. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36835. }
  36836. /**
  36837. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36838. */
  36839. export class PassCubePostProcess extends PostProcess {
  36840. private _face;
  36841. /**
  36842. * Gets or sets the cube face to display.
  36843. * * 0 is +X
  36844. * * 1 is -X
  36845. * * 2 is +Y
  36846. * * 3 is -Y
  36847. * * 4 is +Z
  36848. * * 5 is -Z
  36849. */
  36850. face: number;
  36851. /**
  36852. * Creates the PassCubePostProcess
  36853. * @param name The name of the effect.
  36854. * @param options The required width/height ratio to downsize to before computing the render pass.
  36855. * @param camera The camera to apply the render pass to.
  36856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36857. * @param engine The engine which the post process will be applied. (default: current engine)
  36858. * @param reusable If the post process can be reused on the same frame. (default: false)
  36859. * @param textureType The type of texture to be used when performing the post processing.
  36860. * @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)
  36861. */
  36862. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36863. }
  36864. }
  36865. declare module BABYLON {
  36866. /** @hidden */
  36867. export var anaglyphPixelShader: {
  36868. name: string;
  36869. shader: string;
  36870. };
  36871. }
  36872. declare module BABYLON {
  36873. /**
  36874. * Postprocess used to generate anaglyphic rendering
  36875. */
  36876. export class AnaglyphPostProcess extends PostProcess {
  36877. private _passedProcess;
  36878. /**
  36879. * Creates a new AnaglyphPostProcess
  36880. * @param name defines postprocess name
  36881. * @param options defines creation options or target ratio scale
  36882. * @param rigCameras defines cameras using this postprocess
  36883. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36884. * @param engine defines hosting engine
  36885. * @param reusable defines if the postprocess will be reused multiple times per frame
  36886. */
  36887. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36888. }
  36889. }
  36890. declare module BABYLON {
  36891. /**
  36892. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36893. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36894. */
  36895. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36896. /**
  36897. * Creates a new AnaglyphArcRotateCamera
  36898. * @param name defines camera name
  36899. * @param alpha defines alpha angle (in radians)
  36900. * @param beta defines beta angle (in radians)
  36901. * @param radius defines radius
  36902. * @param target defines camera target
  36903. * @param interaxialDistance defines distance between each color axis
  36904. * @param scene defines the hosting scene
  36905. */
  36906. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36907. /**
  36908. * Gets camera class name
  36909. * @returns AnaglyphArcRotateCamera
  36910. */
  36911. getClassName(): string;
  36912. }
  36913. }
  36914. declare module BABYLON {
  36915. /**
  36916. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36917. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36918. */
  36919. export class AnaglyphFreeCamera extends FreeCamera {
  36920. /**
  36921. * Creates a new AnaglyphFreeCamera
  36922. * @param name defines camera name
  36923. * @param position defines initial position
  36924. * @param interaxialDistance defines distance between each color axis
  36925. * @param scene defines the hosting scene
  36926. */
  36927. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36928. /**
  36929. * Gets camera class name
  36930. * @returns AnaglyphFreeCamera
  36931. */
  36932. getClassName(): string;
  36933. }
  36934. }
  36935. declare module BABYLON {
  36936. /**
  36937. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36938. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36939. */
  36940. export class AnaglyphGamepadCamera extends GamepadCamera {
  36941. /**
  36942. * Creates a new AnaglyphGamepadCamera
  36943. * @param name defines camera name
  36944. * @param position defines initial position
  36945. * @param interaxialDistance defines distance between each color axis
  36946. * @param scene defines the hosting scene
  36947. */
  36948. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36949. /**
  36950. * Gets camera class name
  36951. * @returns AnaglyphGamepadCamera
  36952. */
  36953. getClassName(): string;
  36954. }
  36955. }
  36956. declare module BABYLON {
  36957. /**
  36958. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36959. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36960. */
  36961. export class AnaglyphUniversalCamera extends UniversalCamera {
  36962. /**
  36963. * Creates a new AnaglyphUniversalCamera
  36964. * @param name defines camera name
  36965. * @param position defines initial position
  36966. * @param interaxialDistance defines distance between each color axis
  36967. * @param scene defines the hosting scene
  36968. */
  36969. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36970. /**
  36971. * Gets camera class name
  36972. * @returns AnaglyphUniversalCamera
  36973. */
  36974. getClassName(): string;
  36975. }
  36976. }
  36977. declare module BABYLON {
  36978. /** @hidden */
  36979. export var stereoscopicInterlacePixelShader: {
  36980. name: string;
  36981. shader: string;
  36982. };
  36983. }
  36984. declare module BABYLON {
  36985. /**
  36986. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36987. */
  36988. export class StereoscopicInterlacePostProcess extends PostProcess {
  36989. private _stepSize;
  36990. private _passedProcess;
  36991. /**
  36992. * Initializes a StereoscopicInterlacePostProcess
  36993. * @param name The name of the effect.
  36994. * @param rigCameras The rig cameras to be appled to the post process
  36995. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36997. * @param engine The engine which the post process will be applied. (default: current engine)
  36998. * @param reusable If the post process can be reused on the same frame. (default: false)
  36999. */
  37000. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37001. }
  37002. }
  37003. declare module BABYLON {
  37004. /**
  37005. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37006. * @see http://doc.babylonjs.com/features/cameras
  37007. */
  37008. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37009. /**
  37010. * Creates a new StereoscopicArcRotateCamera
  37011. * @param name defines camera name
  37012. * @param alpha defines alpha angle (in radians)
  37013. * @param beta defines beta angle (in radians)
  37014. * @param radius defines radius
  37015. * @param target defines camera target
  37016. * @param interaxialDistance defines distance between each color axis
  37017. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37018. * @param scene defines the hosting scene
  37019. */
  37020. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37021. /**
  37022. * Gets camera class name
  37023. * @returns StereoscopicArcRotateCamera
  37024. */
  37025. getClassName(): string;
  37026. }
  37027. }
  37028. declare module BABYLON {
  37029. /**
  37030. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37031. * @see http://doc.babylonjs.com/features/cameras
  37032. */
  37033. export class StereoscopicFreeCamera extends FreeCamera {
  37034. /**
  37035. * Creates a new StereoscopicFreeCamera
  37036. * @param name defines camera name
  37037. * @param position defines initial position
  37038. * @param interaxialDistance defines distance between each color axis
  37039. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37040. * @param scene defines the hosting scene
  37041. */
  37042. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37043. /**
  37044. * Gets camera class name
  37045. * @returns StereoscopicFreeCamera
  37046. */
  37047. getClassName(): string;
  37048. }
  37049. }
  37050. declare module BABYLON {
  37051. /**
  37052. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37053. * @see http://doc.babylonjs.com/features/cameras
  37054. */
  37055. export class StereoscopicGamepadCamera extends GamepadCamera {
  37056. /**
  37057. * Creates a new StereoscopicGamepadCamera
  37058. * @param name defines camera name
  37059. * @param position defines initial position
  37060. * @param interaxialDistance defines distance between each color axis
  37061. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37062. * @param scene defines the hosting scene
  37063. */
  37064. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37065. /**
  37066. * Gets camera class name
  37067. * @returns StereoscopicGamepadCamera
  37068. */
  37069. getClassName(): string;
  37070. }
  37071. }
  37072. declare module BABYLON {
  37073. /**
  37074. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37075. * @see http://doc.babylonjs.com/features/cameras
  37076. */
  37077. export class StereoscopicUniversalCamera extends UniversalCamera {
  37078. /**
  37079. * Creates a new StereoscopicUniversalCamera
  37080. * @param name defines camera name
  37081. * @param position defines initial position
  37082. * @param interaxialDistance defines distance between each color axis
  37083. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37084. * @param scene defines the hosting scene
  37085. */
  37086. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37087. /**
  37088. * Gets camera class name
  37089. * @returns StereoscopicUniversalCamera
  37090. */
  37091. getClassName(): string;
  37092. }
  37093. }
  37094. declare module BABYLON {
  37095. /**
  37096. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37097. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37098. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37099. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37100. */
  37101. export class VirtualJoysticksCamera extends FreeCamera {
  37102. /**
  37103. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37104. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37105. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37106. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37107. * @param name Define the name of the camera in the scene
  37108. * @param position Define the start position of the camera in the scene
  37109. * @param scene Define the scene the camera belongs to
  37110. */
  37111. constructor(name: string, position: Vector3, scene: Scene);
  37112. /**
  37113. * Gets the current object class name.
  37114. * @return the class name
  37115. */
  37116. getClassName(): string;
  37117. }
  37118. }
  37119. declare module BABYLON {
  37120. /**
  37121. * This represents all the required metrics to create a VR camera.
  37122. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37123. */
  37124. export class VRCameraMetrics {
  37125. /**
  37126. * Define the horizontal resolution off the screen.
  37127. */
  37128. hResolution: number;
  37129. /**
  37130. * Define the vertical resolution off the screen.
  37131. */
  37132. vResolution: number;
  37133. /**
  37134. * Define the horizontal screen size.
  37135. */
  37136. hScreenSize: number;
  37137. /**
  37138. * Define the vertical screen size.
  37139. */
  37140. vScreenSize: number;
  37141. /**
  37142. * Define the vertical screen center position.
  37143. */
  37144. vScreenCenter: number;
  37145. /**
  37146. * Define the distance of the eyes to the screen.
  37147. */
  37148. eyeToScreenDistance: number;
  37149. /**
  37150. * Define the distance between both lenses
  37151. */
  37152. lensSeparationDistance: number;
  37153. /**
  37154. * Define the distance between both viewer's eyes.
  37155. */
  37156. interpupillaryDistance: number;
  37157. /**
  37158. * Define the distortion factor of the VR postprocess.
  37159. * Please, touch with care.
  37160. */
  37161. distortionK: number[];
  37162. /**
  37163. * Define the chromatic aberration correction factors for the VR post process.
  37164. */
  37165. chromaAbCorrection: number[];
  37166. /**
  37167. * Define the scale factor of the post process.
  37168. * The smaller the better but the slower.
  37169. */
  37170. postProcessScaleFactor: number;
  37171. /**
  37172. * Define an offset for the lens center.
  37173. */
  37174. lensCenterOffset: number;
  37175. /**
  37176. * Define if the current vr camera should compensate the distortion of the lense or not.
  37177. */
  37178. compensateDistortion: boolean;
  37179. /**
  37180. * Defines if multiview should be enabled when rendering (Default: false)
  37181. */
  37182. multiviewEnabled: boolean;
  37183. /**
  37184. * Gets the rendering aspect ratio based on the provided resolutions.
  37185. */
  37186. readonly aspectRatio: number;
  37187. /**
  37188. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37189. */
  37190. readonly aspectRatioFov: number;
  37191. /**
  37192. * @hidden
  37193. */
  37194. readonly leftHMatrix: Matrix;
  37195. /**
  37196. * @hidden
  37197. */
  37198. readonly rightHMatrix: Matrix;
  37199. /**
  37200. * @hidden
  37201. */
  37202. readonly leftPreViewMatrix: Matrix;
  37203. /**
  37204. * @hidden
  37205. */
  37206. readonly rightPreViewMatrix: Matrix;
  37207. /**
  37208. * Get the default VRMetrics based on the most generic setup.
  37209. * @returns the default vr metrics
  37210. */
  37211. static GetDefault(): VRCameraMetrics;
  37212. }
  37213. }
  37214. declare module BABYLON {
  37215. /** @hidden */
  37216. export var vrDistortionCorrectionPixelShader: {
  37217. name: string;
  37218. shader: string;
  37219. };
  37220. }
  37221. declare module BABYLON {
  37222. /**
  37223. * VRDistortionCorrectionPostProcess used for mobile VR
  37224. */
  37225. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37226. private _isRightEye;
  37227. private _distortionFactors;
  37228. private _postProcessScaleFactor;
  37229. private _lensCenterOffset;
  37230. private _scaleIn;
  37231. private _scaleFactor;
  37232. private _lensCenter;
  37233. /**
  37234. * Initializes the VRDistortionCorrectionPostProcess
  37235. * @param name The name of the effect.
  37236. * @param camera The camera to apply the render pass to.
  37237. * @param isRightEye If this is for the right eye distortion
  37238. * @param vrMetrics All the required metrics for the VR camera
  37239. */
  37240. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37241. }
  37242. }
  37243. declare module BABYLON {
  37244. /**
  37245. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37246. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37247. */
  37248. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37249. /**
  37250. * Creates a new VRDeviceOrientationArcRotateCamera
  37251. * @param name defines camera name
  37252. * @param alpha defines the camera rotation along the logitudinal axis
  37253. * @param beta defines the camera rotation along the latitudinal axis
  37254. * @param radius defines the camera distance from its target
  37255. * @param target defines the camera target
  37256. * @param scene defines the scene the camera belongs to
  37257. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37258. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37259. */
  37260. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37261. /**
  37262. * Gets camera class name
  37263. * @returns VRDeviceOrientationArcRotateCamera
  37264. */
  37265. getClassName(): string;
  37266. }
  37267. }
  37268. declare module BABYLON {
  37269. /**
  37270. * Camera used to simulate VR rendering (based on FreeCamera)
  37271. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37272. */
  37273. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37274. /**
  37275. * Creates a new VRDeviceOrientationFreeCamera
  37276. * @param name defines camera name
  37277. * @param position defines the start position of the camera
  37278. * @param scene defines the scene the camera belongs to
  37279. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37280. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37281. */
  37282. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37283. /**
  37284. * Gets camera class name
  37285. * @returns VRDeviceOrientationFreeCamera
  37286. */
  37287. getClassName(): string;
  37288. }
  37289. }
  37290. declare module BABYLON {
  37291. /**
  37292. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37293. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37294. */
  37295. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37296. /**
  37297. * Creates a new VRDeviceOrientationGamepadCamera
  37298. * @param name defines camera name
  37299. * @param position defines the start position of the camera
  37300. * @param scene defines the scene the camera belongs to
  37301. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37302. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37303. */
  37304. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37305. /**
  37306. * Gets camera class name
  37307. * @returns VRDeviceOrientationGamepadCamera
  37308. */
  37309. getClassName(): string;
  37310. }
  37311. }
  37312. declare module BABYLON {
  37313. /**
  37314. * Defines supported buttons for XBox360 compatible gamepads
  37315. */
  37316. export enum Xbox360Button {
  37317. /** A */
  37318. A = 0,
  37319. /** B */
  37320. B = 1,
  37321. /** X */
  37322. X = 2,
  37323. /** Y */
  37324. Y = 3,
  37325. /** Start */
  37326. Start = 4,
  37327. /** Back */
  37328. Back = 5,
  37329. /** Left button */
  37330. LB = 6,
  37331. /** Right button */
  37332. RB = 7,
  37333. /** Left stick */
  37334. LeftStick = 8,
  37335. /** Right stick */
  37336. RightStick = 9
  37337. }
  37338. /** Defines values for XBox360 DPad */
  37339. export enum Xbox360Dpad {
  37340. /** Up */
  37341. Up = 0,
  37342. /** Down */
  37343. Down = 1,
  37344. /** Left */
  37345. Left = 2,
  37346. /** Right */
  37347. Right = 3
  37348. }
  37349. /**
  37350. * Defines a XBox360 gamepad
  37351. */
  37352. export class Xbox360Pad extends Gamepad {
  37353. private _leftTrigger;
  37354. private _rightTrigger;
  37355. private _onlefttriggerchanged;
  37356. private _onrighttriggerchanged;
  37357. private _onbuttondown;
  37358. private _onbuttonup;
  37359. private _ondpaddown;
  37360. private _ondpadup;
  37361. /** Observable raised when a button is pressed */
  37362. onButtonDownObservable: Observable<Xbox360Button>;
  37363. /** Observable raised when a button is released */
  37364. onButtonUpObservable: Observable<Xbox360Button>;
  37365. /** Observable raised when a pad is pressed */
  37366. onPadDownObservable: Observable<Xbox360Dpad>;
  37367. /** Observable raised when a pad is released */
  37368. onPadUpObservable: Observable<Xbox360Dpad>;
  37369. private _buttonA;
  37370. private _buttonB;
  37371. private _buttonX;
  37372. private _buttonY;
  37373. private _buttonBack;
  37374. private _buttonStart;
  37375. private _buttonLB;
  37376. private _buttonRB;
  37377. private _buttonLeftStick;
  37378. private _buttonRightStick;
  37379. private _dPadUp;
  37380. private _dPadDown;
  37381. private _dPadLeft;
  37382. private _dPadRight;
  37383. private _isXboxOnePad;
  37384. /**
  37385. * Creates a new XBox360 gamepad object
  37386. * @param id defines the id of this gamepad
  37387. * @param index defines its index
  37388. * @param gamepad defines the internal HTML gamepad object
  37389. * @param xboxOne defines if it is a XBox One gamepad
  37390. */
  37391. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37392. /**
  37393. * Defines the callback to call when left trigger is pressed
  37394. * @param callback defines the callback to use
  37395. */
  37396. onlefttriggerchanged(callback: (value: number) => void): void;
  37397. /**
  37398. * Defines the callback to call when right trigger is pressed
  37399. * @param callback defines the callback to use
  37400. */
  37401. onrighttriggerchanged(callback: (value: number) => void): void;
  37402. /**
  37403. * Gets the left trigger value
  37404. */
  37405. /**
  37406. * Sets the left trigger value
  37407. */
  37408. leftTrigger: number;
  37409. /**
  37410. * Gets the right trigger value
  37411. */
  37412. /**
  37413. * Sets the right trigger value
  37414. */
  37415. rightTrigger: number;
  37416. /**
  37417. * Defines the callback to call when a button is pressed
  37418. * @param callback defines the callback to use
  37419. */
  37420. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37421. /**
  37422. * Defines the callback to call when a button is released
  37423. * @param callback defines the callback to use
  37424. */
  37425. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37426. /**
  37427. * Defines the callback to call when a pad is pressed
  37428. * @param callback defines the callback to use
  37429. */
  37430. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37431. /**
  37432. * Defines the callback to call when a pad is released
  37433. * @param callback defines the callback to use
  37434. */
  37435. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37436. private _setButtonValue;
  37437. private _setDPadValue;
  37438. /**
  37439. * Gets the value of the `A` button
  37440. */
  37441. /**
  37442. * Sets the value of the `A` button
  37443. */
  37444. buttonA: number;
  37445. /**
  37446. * Gets the value of the `B` button
  37447. */
  37448. /**
  37449. * Sets the value of the `B` button
  37450. */
  37451. buttonB: number;
  37452. /**
  37453. * Gets the value of the `X` button
  37454. */
  37455. /**
  37456. * Sets the value of the `X` button
  37457. */
  37458. buttonX: number;
  37459. /**
  37460. * Gets the value of the `Y` button
  37461. */
  37462. /**
  37463. * Sets the value of the `Y` button
  37464. */
  37465. buttonY: number;
  37466. /**
  37467. * Gets the value of the `Start` button
  37468. */
  37469. /**
  37470. * Sets the value of the `Start` button
  37471. */
  37472. buttonStart: number;
  37473. /**
  37474. * Gets the value of the `Back` button
  37475. */
  37476. /**
  37477. * Sets the value of the `Back` button
  37478. */
  37479. buttonBack: number;
  37480. /**
  37481. * Gets the value of the `Left` button
  37482. */
  37483. /**
  37484. * Sets the value of the `Left` button
  37485. */
  37486. buttonLB: number;
  37487. /**
  37488. * Gets the value of the `Right` button
  37489. */
  37490. /**
  37491. * Sets the value of the `Right` button
  37492. */
  37493. buttonRB: number;
  37494. /**
  37495. * Gets the value of the Left joystick
  37496. */
  37497. /**
  37498. * Sets the value of the Left joystick
  37499. */
  37500. buttonLeftStick: number;
  37501. /**
  37502. * Gets the value of the Right joystick
  37503. */
  37504. /**
  37505. * Sets the value of the Right joystick
  37506. */
  37507. buttonRightStick: number;
  37508. /**
  37509. * Gets the value of D-pad up
  37510. */
  37511. /**
  37512. * Sets the value of D-pad up
  37513. */
  37514. dPadUp: number;
  37515. /**
  37516. * Gets the value of D-pad down
  37517. */
  37518. /**
  37519. * Sets the value of D-pad down
  37520. */
  37521. dPadDown: number;
  37522. /**
  37523. * Gets the value of D-pad left
  37524. */
  37525. /**
  37526. * Sets the value of D-pad left
  37527. */
  37528. dPadLeft: number;
  37529. /**
  37530. * Gets the value of D-pad right
  37531. */
  37532. /**
  37533. * Sets the value of D-pad right
  37534. */
  37535. dPadRight: number;
  37536. /**
  37537. * Force the gamepad to synchronize with device values
  37538. */
  37539. update(): void;
  37540. /**
  37541. * Disposes the gamepad
  37542. */
  37543. dispose(): void;
  37544. }
  37545. }
  37546. declare module BABYLON {
  37547. /**
  37548. * Base class of materials working in push mode in babylon JS
  37549. * @hidden
  37550. */
  37551. export class PushMaterial extends Material {
  37552. protected _activeEffect: Effect;
  37553. protected _normalMatrix: Matrix;
  37554. /**
  37555. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37556. * This means that the material can keep using a previous shader while a new one is being compiled.
  37557. * This is mostly used when shader parallel compilation is supported (true by default)
  37558. */
  37559. allowShaderHotSwapping: boolean;
  37560. constructor(name: string, scene: Scene);
  37561. getEffect(): Effect;
  37562. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37563. /**
  37564. * Binds the given world matrix to the active effect
  37565. *
  37566. * @param world the matrix to bind
  37567. */
  37568. bindOnlyWorldMatrix(world: Matrix): void;
  37569. /**
  37570. * Binds the given normal matrix to the active effect
  37571. *
  37572. * @param normalMatrix the matrix to bind
  37573. */
  37574. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37575. bind(world: Matrix, mesh?: Mesh): void;
  37576. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37577. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37578. }
  37579. }
  37580. declare module BABYLON {
  37581. /**
  37582. * This groups all the flags used to control the materials channel.
  37583. */
  37584. export class MaterialFlags {
  37585. private static _DiffuseTextureEnabled;
  37586. /**
  37587. * Are diffuse textures enabled in the application.
  37588. */
  37589. static DiffuseTextureEnabled: boolean;
  37590. private static _AmbientTextureEnabled;
  37591. /**
  37592. * Are ambient textures enabled in the application.
  37593. */
  37594. static AmbientTextureEnabled: boolean;
  37595. private static _OpacityTextureEnabled;
  37596. /**
  37597. * Are opacity textures enabled in the application.
  37598. */
  37599. static OpacityTextureEnabled: boolean;
  37600. private static _ReflectionTextureEnabled;
  37601. /**
  37602. * Are reflection textures enabled in the application.
  37603. */
  37604. static ReflectionTextureEnabled: boolean;
  37605. private static _EmissiveTextureEnabled;
  37606. /**
  37607. * Are emissive textures enabled in the application.
  37608. */
  37609. static EmissiveTextureEnabled: boolean;
  37610. private static _SpecularTextureEnabled;
  37611. /**
  37612. * Are specular textures enabled in the application.
  37613. */
  37614. static SpecularTextureEnabled: boolean;
  37615. private static _BumpTextureEnabled;
  37616. /**
  37617. * Are bump textures enabled in the application.
  37618. */
  37619. static BumpTextureEnabled: boolean;
  37620. private static _LightmapTextureEnabled;
  37621. /**
  37622. * Are lightmap textures enabled in the application.
  37623. */
  37624. static LightmapTextureEnabled: boolean;
  37625. private static _RefractionTextureEnabled;
  37626. /**
  37627. * Are refraction textures enabled in the application.
  37628. */
  37629. static RefractionTextureEnabled: boolean;
  37630. private static _ColorGradingTextureEnabled;
  37631. /**
  37632. * Are color grading textures enabled in the application.
  37633. */
  37634. static ColorGradingTextureEnabled: boolean;
  37635. private static _FresnelEnabled;
  37636. /**
  37637. * Are fresnels enabled in the application.
  37638. */
  37639. static FresnelEnabled: boolean;
  37640. private static _ClearCoatTextureEnabled;
  37641. /**
  37642. * Are clear coat textures enabled in the application.
  37643. */
  37644. static ClearCoatTextureEnabled: boolean;
  37645. private static _ClearCoatBumpTextureEnabled;
  37646. /**
  37647. * Are clear coat bump textures enabled in the application.
  37648. */
  37649. static ClearCoatBumpTextureEnabled: boolean;
  37650. private static _ClearCoatTintTextureEnabled;
  37651. /**
  37652. * Are clear coat tint textures enabled in the application.
  37653. */
  37654. static ClearCoatTintTextureEnabled: boolean;
  37655. private static _SheenTextureEnabled;
  37656. /**
  37657. * Are sheen textures enabled in the application.
  37658. */
  37659. static SheenTextureEnabled: boolean;
  37660. private static _AnisotropicTextureEnabled;
  37661. /**
  37662. * Are anisotropic textures enabled in the application.
  37663. */
  37664. static AnisotropicTextureEnabled: boolean;
  37665. private static _ThicknessTextureEnabled;
  37666. /**
  37667. * Are thickness textures enabled in the application.
  37668. */
  37669. static ThicknessTextureEnabled: boolean;
  37670. }
  37671. }
  37672. declare module BABYLON {
  37673. /** @hidden */
  37674. export var defaultFragmentDeclaration: {
  37675. name: string;
  37676. shader: string;
  37677. };
  37678. }
  37679. declare module BABYLON {
  37680. /** @hidden */
  37681. export var defaultUboDeclaration: {
  37682. name: string;
  37683. shader: string;
  37684. };
  37685. }
  37686. declare module BABYLON {
  37687. /** @hidden */
  37688. export var lightFragmentDeclaration: {
  37689. name: string;
  37690. shader: string;
  37691. };
  37692. }
  37693. declare module BABYLON {
  37694. /** @hidden */
  37695. export var lightUboDeclaration: {
  37696. name: string;
  37697. shader: string;
  37698. };
  37699. }
  37700. declare module BABYLON {
  37701. /** @hidden */
  37702. export var lightsFragmentFunctions: {
  37703. name: string;
  37704. shader: string;
  37705. };
  37706. }
  37707. declare module BABYLON {
  37708. /** @hidden */
  37709. export var shadowsFragmentFunctions: {
  37710. name: string;
  37711. shader: string;
  37712. };
  37713. }
  37714. declare module BABYLON {
  37715. /** @hidden */
  37716. export var fresnelFunction: {
  37717. name: string;
  37718. shader: string;
  37719. };
  37720. }
  37721. declare module BABYLON {
  37722. /** @hidden */
  37723. export var reflectionFunction: {
  37724. name: string;
  37725. shader: string;
  37726. };
  37727. }
  37728. declare module BABYLON {
  37729. /** @hidden */
  37730. export var bumpFragmentFunctions: {
  37731. name: string;
  37732. shader: string;
  37733. };
  37734. }
  37735. declare module BABYLON {
  37736. /** @hidden */
  37737. export var logDepthDeclaration: {
  37738. name: string;
  37739. shader: string;
  37740. };
  37741. }
  37742. declare module BABYLON {
  37743. /** @hidden */
  37744. export var bumpFragment: {
  37745. name: string;
  37746. shader: string;
  37747. };
  37748. }
  37749. declare module BABYLON {
  37750. /** @hidden */
  37751. export var depthPrePass: {
  37752. name: string;
  37753. shader: string;
  37754. };
  37755. }
  37756. declare module BABYLON {
  37757. /** @hidden */
  37758. export var lightFragment: {
  37759. name: string;
  37760. shader: string;
  37761. };
  37762. }
  37763. declare module BABYLON {
  37764. /** @hidden */
  37765. export var logDepthFragment: {
  37766. name: string;
  37767. shader: string;
  37768. };
  37769. }
  37770. declare module BABYLON {
  37771. /** @hidden */
  37772. export var defaultPixelShader: {
  37773. name: string;
  37774. shader: string;
  37775. };
  37776. }
  37777. declare module BABYLON {
  37778. /** @hidden */
  37779. export var defaultVertexDeclaration: {
  37780. name: string;
  37781. shader: string;
  37782. };
  37783. }
  37784. declare module BABYLON {
  37785. /** @hidden */
  37786. export var bumpVertexDeclaration: {
  37787. name: string;
  37788. shader: string;
  37789. };
  37790. }
  37791. declare module BABYLON {
  37792. /** @hidden */
  37793. export var bumpVertex: {
  37794. name: string;
  37795. shader: string;
  37796. };
  37797. }
  37798. declare module BABYLON {
  37799. /** @hidden */
  37800. export var fogVertex: {
  37801. name: string;
  37802. shader: string;
  37803. };
  37804. }
  37805. declare module BABYLON {
  37806. /** @hidden */
  37807. export var shadowsVertex: {
  37808. name: string;
  37809. shader: string;
  37810. };
  37811. }
  37812. declare module BABYLON {
  37813. /** @hidden */
  37814. export var pointCloudVertex: {
  37815. name: string;
  37816. shader: string;
  37817. };
  37818. }
  37819. declare module BABYLON {
  37820. /** @hidden */
  37821. export var logDepthVertex: {
  37822. name: string;
  37823. shader: string;
  37824. };
  37825. }
  37826. declare module BABYLON {
  37827. /** @hidden */
  37828. export var defaultVertexShader: {
  37829. name: string;
  37830. shader: string;
  37831. };
  37832. }
  37833. declare module BABYLON {
  37834. /** @hidden */
  37835. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37836. MAINUV1: boolean;
  37837. MAINUV2: boolean;
  37838. DIFFUSE: boolean;
  37839. DIFFUSEDIRECTUV: number;
  37840. AMBIENT: boolean;
  37841. AMBIENTDIRECTUV: number;
  37842. OPACITY: boolean;
  37843. OPACITYDIRECTUV: number;
  37844. OPACITYRGB: boolean;
  37845. REFLECTION: boolean;
  37846. EMISSIVE: boolean;
  37847. EMISSIVEDIRECTUV: number;
  37848. SPECULAR: boolean;
  37849. SPECULARDIRECTUV: number;
  37850. BUMP: boolean;
  37851. BUMPDIRECTUV: number;
  37852. PARALLAX: boolean;
  37853. PARALLAXOCCLUSION: boolean;
  37854. SPECULAROVERALPHA: boolean;
  37855. CLIPPLANE: boolean;
  37856. CLIPPLANE2: boolean;
  37857. CLIPPLANE3: boolean;
  37858. CLIPPLANE4: boolean;
  37859. ALPHATEST: boolean;
  37860. DEPTHPREPASS: boolean;
  37861. ALPHAFROMDIFFUSE: boolean;
  37862. POINTSIZE: boolean;
  37863. FOG: boolean;
  37864. SPECULARTERM: boolean;
  37865. DIFFUSEFRESNEL: boolean;
  37866. OPACITYFRESNEL: boolean;
  37867. REFLECTIONFRESNEL: boolean;
  37868. REFRACTIONFRESNEL: boolean;
  37869. EMISSIVEFRESNEL: boolean;
  37870. FRESNEL: boolean;
  37871. NORMAL: boolean;
  37872. UV1: boolean;
  37873. UV2: boolean;
  37874. VERTEXCOLOR: boolean;
  37875. VERTEXALPHA: boolean;
  37876. NUM_BONE_INFLUENCERS: number;
  37877. BonesPerMesh: number;
  37878. BONETEXTURE: boolean;
  37879. INSTANCES: boolean;
  37880. GLOSSINESS: boolean;
  37881. ROUGHNESS: boolean;
  37882. EMISSIVEASILLUMINATION: boolean;
  37883. LINKEMISSIVEWITHDIFFUSE: boolean;
  37884. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37885. LIGHTMAP: boolean;
  37886. LIGHTMAPDIRECTUV: number;
  37887. OBJECTSPACE_NORMALMAP: boolean;
  37888. USELIGHTMAPASSHADOWMAP: boolean;
  37889. REFLECTIONMAP_3D: boolean;
  37890. REFLECTIONMAP_SPHERICAL: boolean;
  37891. REFLECTIONMAP_PLANAR: boolean;
  37892. REFLECTIONMAP_CUBIC: boolean;
  37893. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37894. REFLECTIONMAP_PROJECTION: boolean;
  37895. REFLECTIONMAP_SKYBOX: boolean;
  37896. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37897. REFLECTIONMAP_EXPLICIT: boolean;
  37898. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37899. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37900. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37901. INVERTCUBICMAP: boolean;
  37902. LOGARITHMICDEPTH: boolean;
  37903. REFRACTION: boolean;
  37904. REFRACTIONMAP_3D: boolean;
  37905. REFLECTIONOVERALPHA: boolean;
  37906. TWOSIDEDLIGHTING: boolean;
  37907. SHADOWFLOAT: boolean;
  37908. MORPHTARGETS: boolean;
  37909. MORPHTARGETS_NORMAL: boolean;
  37910. MORPHTARGETS_TANGENT: boolean;
  37911. NUM_MORPH_INFLUENCERS: number;
  37912. NONUNIFORMSCALING: boolean;
  37913. PREMULTIPLYALPHA: boolean;
  37914. IMAGEPROCESSING: boolean;
  37915. VIGNETTE: boolean;
  37916. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37917. VIGNETTEBLENDMODEOPAQUE: boolean;
  37918. TONEMAPPING: boolean;
  37919. TONEMAPPING_ACES: boolean;
  37920. CONTRAST: boolean;
  37921. COLORCURVES: boolean;
  37922. COLORGRADING: boolean;
  37923. COLORGRADING3D: boolean;
  37924. SAMPLER3DGREENDEPTH: boolean;
  37925. SAMPLER3DBGRMAP: boolean;
  37926. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37927. MULTIVIEW: boolean;
  37928. /**
  37929. * If the reflection texture on this material is in linear color space
  37930. * @hidden
  37931. */
  37932. IS_REFLECTION_LINEAR: boolean;
  37933. /**
  37934. * If the refraction texture on this material is in linear color space
  37935. * @hidden
  37936. */
  37937. IS_REFRACTION_LINEAR: boolean;
  37938. EXPOSURE: boolean;
  37939. constructor();
  37940. setReflectionMode(modeToEnable: string): void;
  37941. }
  37942. /**
  37943. * This is the default material used in Babylon. It is the best trade off between quality
  37944. * and performances.
  37945. * @see http://doc.babylonjs.com/babylon101/materials
  37946. */
  37947. export class StandardMaterial extends PushMaterial {
  37948. private _diffuseTexture;
  37949. /**
  37950. * The basic texture of the material as viewed under a light.
  37951. */
  37952. diffuseTexture: Nullable<BaseTexture>;
  37953. private _ambientTexture;
  37954. /**
  37955. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37956. */
  37957. ambientTexture: Nullable<BaseTexture>;
  37958. private _opacityTexture;
  37959. /**
  37960. * Define the transparency of the material from a texture.
  37961. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37962. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37963. */
  37964. opacityTexture: Nullable<BaseTexture>;
  37965. private _reflectionTexture;
  37966. /**
  37967. * Define the texture used to display the reflection.
  37968. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37969. */
  37970. reflectionTexture: Nullable<BaseTexture>;
  37971. private _emissiveTexture;
  37972. /**
  37973. * Define texture of the material as if self lit.
  37974. * This will be mixed in the final result even in the absence of light.
  37975. */
  37976. emissiveTexture: Nullable<BaseTexture>;
  37977. private _specularTexture;
  37978. /**
  37979. * Define how the color and intensity of the highlight given by the light in the material.
  37980. */
  37981. specularTexture: Nullable<BaseTexture>;
  37982. private _bumpTexture;
  37983. /**
  37984. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  37985. * 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.
  37986. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  37987. */
  37988. bumpTexture: Nullable<BaseTexture>;
  37989. private _lightmapTexture;
  37990. /**
  37991. * Complex lighting can be computationally expensive to compute at runtime.
  37992. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  37993. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  37994. */
  37995. lightmapTexture: Nullable<BaseTexture>;
  37996. private _refractionTexture;
  37997. /**
  37998. * Define the texture used to display the refraction.
  37999. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38000. */
  38001. refractionTexture: Nullable<BaseTexture>;
  38002. /**
  38003. * The color of the material lit by the environmental background lighting.
  38004. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38005. */
  38006. ambientColor: Color3;
  38007. /**
  38008. * The basic color of the material as viewed under a light.
  38009. */
  38010. diffuseColor: Color3;
  38011. /**
  38012. * Define how the color and intensity of the highlight given by the light in the material.
  38013. */
  38014. specularColor: Color3;
  38015. /**
  38016. * Define the color of the material as if self lit.
  38017. * This will be mixed in the final result even in the absence of light.
  38018. */
  38019. emissiveColor: Color3;
  38020. /**
  38021. * Defines how sharp are the highlights in the material.
  38022. * The bigger the value the sharper giving a more glossy feeling to the result.
  38023. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38024. */
  38025. specularPower: number;
  38026. private _useAlphaFromDiffuseTexture;
  38027. /**
  38028. * Does the transparency come from the diffuse texture alpha channel.
  38029. */
  38030. useAlphaFromDiffuseTexture: boolean;
  38031. private _useEmissiveAsIllumination;
  38032. /**
  38033. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38034. */
  38035. useEmissiveAsIllumination: boolean;
  38036. private _linkEmissiveWithDiffuse;
  38037. /**
  38038. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38039. * the emissive level when the final color is close to one.
  38040. */
  38041. linkEmissiveWithDiffuse: boolean;
  38042. private _useSpecularOverAlpha;
  38043. /**
  38044. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38045. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38046. */
  38047. useSpecularOverAlpha: boolean;
  38048. private _useReflectionOverAlpha;
  38049. /**
  38050. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38051. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38052. */
  38053. useReflectionOverAlpha: boolean;
  38054. private _disableLighting;
  38055. /**
  38056. * Does lights from the scene impacts this material.
  38057. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38058. */
  38059. disableLighting: boolean;
  38060. private _useObjectSpaceNormalMap;
  38061. /**
  38062. * Allows using an object space normal map (instead of tangent space).
  38063. */
  38064. useObjectSpaceNormalMap: boolean;
  38065. private _useParallax;
  38066. /**
  38067. * Is parallax enabled or not.
  38068. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38069. */
  38070. useParallax: boolean;
  38071. private _useParallaxOcclusion;
  38072. /**
  38073. * Is parallax occlusion enabled or not.
  38074. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38075. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38076. */
  38077. useParallaxOcclusion: boolean;
  38078. /**
  38079. * 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.
  38080. */
  38081. parallaxScaleBias: number;
  38082. private _roughness;
  38083. /**
  38084. * Helps to define how blurry the reflections should appears in the material.
  38085. */
  38086. roughness: number;
  38087. /**
  38088. * In case of refraction, define the value of the indice of refraction.
  38089. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38090. */
  38091. indexOfRefraction: number;
  38092. /**
  38093. * Invert the refraction texture alongside the y axis.
  38094. * It can be useful with procedural textures or probe for instance.
  38095. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38096. */
  38097. invertRefractionY: boolean;
  38098. /**
  38099. * Defines the alpha limits in alpha test mode.
  38100. */
  38101. alphaCutOff: number;
  38102. private _useLightmapAsShadowmap;
  38103. /**
  38104. * In case of light mapping, define whether the map contains light or shadow informations.
  38105. */
  38106. useLightmapAsShadowmap: boolean;
  38107. private _diffuseFresnelParameters;
  38108. /**
  38109. * Define the diffuse fresnel parameters of the material.
  38110. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38111. */
  38112. diffuseFresnelParameters: FresnelParameters;
  38113. private _opacityFresnelParameters;
  38114. /**
  38115. * Define the opacity fresnel parameters of the material.
  38116. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38117. */
  38118. opacityFresnelParameters: FresnelParameters;
  38119. private _reflectionFresnelParameters;
  38120. /**
  38121. * Define the reflection fresnel parameters of the material.
  38122. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38123. */
  38124. reflectionFresnelParameters: FresnelParameters;
  38125. private _refractionFresnelParameters;
  38126. /**
  38127. * Define the refraction fresnel parameters of the material.
  38128. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38129. */
  38130. refractionFresnelParameters: FresnelParameters;
  38131. private _emissiveFresnelParameters;
  38132. /**
  38133. * Define the emissive fresnel parameters of the material.
  38134. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38135. */
  38136. emissiveFresnelParameters: FresnelParameters;
  38137. private _useReflectionFresnelFromSpecular;
  38138. /**
  38139. * If true automatically deducts the fresnels values from the material specularity.
  38140. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38141. */
  38142. useReflectionFresnelFromSpecular: boolean;
  38143. private _useGlossinessFromSpecularMapAlpha;
  38144. /**
  38145. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38146. */
  38147. useGlossinessFromSpecularMapAlpha: boolean;
  38148. private _maxSimultaneousLights;
  38149. /**
  38150. * Defines the maximum number of lights that can be used in the material
  38151. */
  38152. maxSimultaneousLights: number;
  38153. private _invertNormalMapX;
  38154. /**
  38155. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38156. */
  38157. invertNormalMapX: boolean;
  38158. private _invertNormalMapY;
  38159. /**
  38160. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38161. */
  38162. invertNormalMapY: boolean;
  38163. private _twoSidedLighting;
  38164. /**
  38165. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38166. */
  38167. twoSidedLighting: boolean;
  38168. /**
  38169. * Default configuration related to image processing available in the standard Material.
  38170. */
  38171. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38172. /**
  38173. * Gets the image processing configuration used either in this material.
  38174. */
  38175. /**
  38176. * Sets the Default image processing configuration used either in the this material.
  38177. *
  38178. * If sets to null, the scene one is in use.
  38179. */
  38180. imageProcessingConfiguration: ImageProcessingConfiguration;
  38181. /**
  38182. * Keep track of the image processing observer to allow dispose and replace.
  38183. */
  38184. private _imageProcessingObserver;
  38185. /**
  38186. * Attaches a new image processing configuration to the Standard Material.
  38187. * @param configuration
  38188. */
  38189. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38190. /**
  38191. * Gets wether the color curves effect is enabled.
  38192. */
  38193. /**
  38194. * Sets wether the color curves effect is enabled.
  38195. */
  38196. cameraColorCurvesEnabled: boolean;
  38197. /**
  38198. * Gets wether the color grading effect is enabled.
  38199. */
  38200. /**
  38201. * Gets wether the color grading effect is enabled.
  38202. */
  38203. cameraColorGradingEnabled: boolean;
  38204. /**
  38205. * Gets wether tonemapping is enabled or not.
  38206. */
  38207. /**
  38208. * Sets wether tonemapping is enabled or not
  38209. */
  38210. cameraToneMappingEnabled: boolean;
  38211. /**
  38212. * The camera exposure used on this material.
  38213. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38214. * This corresponds to a photographic exposure.
  38215. */
  38216. /**
  38217. * The camera exposure used on this material.
  38218. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38219. * This corresponds to a photographic exposure.
  38220. */
  38221. cameraExposure: number;
  38222. /**
  38223. * Gets The camera contrast used on this material.
  38224. */
  38225. /**
  38226. * Sets The camera contrast used on this material.
  38227. */
  38228. cameraContrast: number;
  38229. /**
  38230. * Gets the Color Grading 2D Lookup Texture.
  38231. */
  38232. /**
  38233. * Sets the Color Grading 2D Lookup Texture.
  38234. */
  38235. cameraColorGradingTexture: Nullable<BaseTexture>;
  38236. /**
  38237. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38238. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38239. * 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;
  38240. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38241. */
  38242. /**
  38243. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38244. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38245. * 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;
  38246. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38247. */
  38248. cameraColorCurves: Nullable<ColorCurves>;
  38249. /**
  38250. * Custom callback helping to override the default shader used in the material.
  38251. */
  38252. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38253. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38254. protected _worldViewProjectionMatrix: Matrix;
  38255. protected _globalAmbientColor: Color3;
  38256. protected _useLogarithmicDepth: boolean;
  38257. /**
  38258. * Instantiates a new standard material.
  38259. * This is the default material used in Babylon. It is the best trade off between quality
  38260. * and performances.
  38261. * @see http://doc.babylonjs.com/babylon101/materials
  38262. * @param name Define the name of the material in the scene
  38263. * @param scene Define the scene the material belong to
  38264. */
  38265. constructor(name: string, scene: Scene);
  38266. /**
  38267. * Gets a boolean indicating that current material needs to register RTT
  38268. */
  38269. readonly hasRenderTargetTextures: boolean;
  38270. /**
  38271. * Gets the current class name of the material e.g. "StandardMaterial"
  38272. * Mainly use in serialization.
  38273. * @returns the class name
  38274. */
  38275. getClassName(): string;
  38276. /**
  38277. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38278. * You can try switching to logarithmic depth.
  38279. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38280. */
  38281. useLogarithmicDepth: boolean;
  38282. /**
  38283. * Specifies if the material will require alpha blending
  38284. * @returns a boolean specifying if alpha blending is needed
  38285. */
  38286. needAlphaBlending(): boolean;
  38287. /**
  38288. * Specifies if this material should be rendered in alpha test mode
  38289. * @returns a boolean specifying if an alpha test is needed.
  38290. */
  38291. needAlphaTesting(): boolean;
  38292. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38293. /**
  38294. * Get the texture used for alpha test purpose.
  38295. * @returns the diffuse texture in case of the standard material.
  38296. */
  38297. getAlphaTestTexture(): Nullable<BaseTexture>;
  38298. /**
  38299. * Get if the submesh is ready to be used and all its information available.
  38300. * Child classes can use it to update shaders
  38301. * @param mesh defines the mesh to check
  38302. * @param subMesh defines which submesh to check
  38303. * @param useInstances specifies that instances should be used
  38304. * @returns a boolean indicating that the submesh is ready or not
  38305. */
  38306. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38307. /**
  38308. * Builds the material UBO layouts.
  38309. * Used internally during the effect preparation.
  38310. */
  38311. buildUniformLayout(): void;
  38312. /**
  38313. * Unbinds the material from the mesh
  38314. */
  38315. unbind(): void;
  38316. /**
  38317. * Binds the submesh to this material by preparing the effect and shader to draw
  38318. * @param world defines the world transformation matrix
  38319. * @param mesh defines the mesh containing the submesh
  38320. * @param subMesh defines the submesh to bind the material to
  38321. */
  38322. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38323. /**
  38324. * Get the list of animatables in the material.
  38325. * @returns the list of animatables object used in the material
  38326. */
  38327. getAnimatables(): IAnimatable[];
  38328. /**
  38329. * Gets the active textures from the material
  38330. * @returns an array of textures
  38331. */
  38332. getActiveTextures(): BaseTexture[];
  38333. /**
  38334. * Specifies if the material uses a texture
  38335. * @param texture defines the texture to check against the material
  38336. * @returns a boolean specifying if the material uses the texture
  38337. */
  38338. hasTexture(texture: BaseTexture): boolean;
  38339. /**
  38340. * Disposes the material
  38341. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38342. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38343. */
  38344. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38345. /**
  38346. * Makes a duplicate of the material, and gives it a new name
  38347. * @param name defines the new name for the duplicated material
  38348. * @returns the cloned material
  38349. */
  38350. clone(name: string): StandardMaterial;
  38351. /**
  38352. * Serializes this material in a JSON representation
  38353. * @returns the serialized material object
  38354. */
  38355. serialize(): any;
  38356. /**
  38357. * Creates a standard material from parsed material data
  38358. * @param source defines the JSON representation of the material
  38359. * @param scene defines the hosting scene
  38360. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38361. * @returns a new standard material
  38362. */
  38363. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38364. /**
  38365. * Are diffuse textures enabled in the application.
  38366. */
  38367. static DiffuseTextureEnabled: boolean;
  38368. /**
  38369. * Are ambient textures enabled in the application.
  38370. */
  38371. static AmbientTextureEnabled: boolean;
  38372. /**
  38373. * Are opacity textures enabled in the application.
  38374. */
  38375. static OpacityTextureEnabled: boolean;
  38376. /**
  38377. * Are reflection textures enabled in the application.
  38378. */
  38379. static ReflectionTextureEnabled: boolean;
  38380. /**
  38381. * Are emissive textures enabled in the application.
  38382. */
  38383. static EmissiveTextureEnabled: boolean;
  38384. /**
  38385. * Are specular textures enabled in the application.
  38386. */
  38387. static SpecularTextureEnabled: boolean;
  38388. /**
  38389. * Are bump textures enabled in the application.
  38390. */
  38391. static BumpTextureEnabled: boolean;
  38392. /**
  38393. * Are lightmap textures enabled in the application.
  38394. */
  38395. static LightmapTextureEnabled: boolean;
  38396. /**
  38397. * Are refraction textures enabled in the application.
  38398. */
  38399. static RefractionTextureEnabled: boolean;
  38400. /**
  38401. * Are color grading textures enabled in the application.
  38402. */
  38403. static ColorGradingTextureEnabled: boolean;
  38404. /**
  38405. * Are fresnels enabled in the application.
  38406. */
  38407. static FresnelEnabled: boolean;
  38408. }
  38409. }
  38410. declare module BABYLON {
  38411. /**
  38412. * A class extending Texture allowing drawing on a texture
  38413. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38414. */
  38415. export class DynamicTexture extends Texture {
  38416. private _generateMipMaps;
  38417. private _canvas;
  38418. private _context;
  38419. private _engine;
  38420. /**
  38421. * Creates a DynamicTexture
  38422. * @param name defines the name of the texture
  38423. * @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
  38424. * @param scene defines the scene where you want the texture
  38425. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38426. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38427. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38428. */
  38429. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38430. /**
  38431. * Get the current class name of the texture useful for serialization or dynamic coding.
  38432. * @returns "DynamicTexture"
  38433. */
  38434. getClassName(): string;
  38435. /**
  38436. * Gets the current state of canRescale
  38437. */
  38438. readonly canRescale: boolean;
  38439. private _recreate;
  38440. /**
  38441. * Scales the texture
  38442. * @param ratio the scale factor to apply to both width and height
  38443. */
  38444. scale(ratio: number): void;
  38445. /**
  38446. * Resizes the texture
  38447. * @param width the new width
  38448. * @param height the new height
  38449. */
  38450. scaleTo(width: number, height: number): void;
  38451. /**
  38452. * Gets the context of the canvas used by the texture
  38453. * @returns the canvas context of the dynamic texture
  38454. */
  38455. getContext(): CanvasRenderingContext2D;
  38456. /**
  38457. * Clears the texture
  38458. */
  38459. clear(): void;
  38460. /**
  38461. * Updates the texture
  38462. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38463. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38464. */
  38465. update(invertY?: boolean, premulAlpha?: boolean): void;
  38466. /**
  38467. * Draws text onto the texture
  38468. * @param text defines the text to be drawn
  38469. * @param x defines the placement of the text from the left
  38470. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38471. * @param font defines the font to be used with font-style, font-size, font-name
  38472. * @param color defines the color used for the text
  38473. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38474. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38475. * @param update defines whether texture is immediately update (default is true)
  38476. */
  38477. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38478. /**
  38479. * Clones the texture
  38480. * @returns the clone of the texture.
  38481. */
  38482. clone(): DynamicTexture;
  38483. /**
  38484. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38485. * @returns a serialized dynamic texture object
  38486. */
  38487. serialize(): any;
  38488. /** @hidden */ rebuild(): void;
  38489. }
  38490. }
  38491. declare module BABYLON {
  38492. /** @hidden */
  38493. export var imageProcessingPixelShader: {
  38494. name: string;
  38495. shader: string;
  38496. };
  38497. }
  38498. declare module BABYLON {
  38499. /**
  38500. * ImageProcessingPostProcess
  38501. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38502. */
  38503. export class ImageProcessingPostProcess extends PostProcess {
  38504. /**
  38505. * Default configuration related to image processing available in the PBR Material.
  38506. */
  38507. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38508. /**
  38509. * Gets the image processing configuration used either in this material.
  38510. */
  38511. /**
  38512. * Sets the Default image processing configuration used either in the this material.
  38513. *
  38514. * If sets to null, the scene one is in use.
  38515. */
  38516. imageProcessingConfiguration: ImageProcessingConfiguration;
  38517. /**
  38518. * Keep track of the image processing observer to allow dispose and replace.
  38519. */
  38520. private _imageProcessingObserver;
  38521. /**
  38522. * Attaches a new image processing configuration to the PBR Material.
  38523. * @param configuration
  38524. */
  38525. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38526. /**
  38527. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38528. */
  38529. /**
  38530. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38531. */
  38532. colorCurves: Nullable<ColorCurves>;
  38533. /**
  38534. * Gets wether the color curves effect is enabled.
  38535. */
  38536. /**
  38537. * Sets wether the color curves effect is enabled.
  38538. */
  38539. colorCurvesEnabled: boolean;
  38540. /**
  38541. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38542. */
  38543. /**
  38544. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38545. */
  38546. colorGradingTexture: Nullable<BaseTexture>;
  38547. /**
  38548. * Gets wether the color grading effect is enabled.
  38549. */
  38550. /**
  38551. * Gets wether the color grading effect is enabled.
  38552. */
  38553. colorGradingEnabled: boolean;
  38554. /**
  38555. * Gets exposure used in the effect.
  38556. */
  38557. /**
  38558. * Sets exposure used in the effect.
  38559. */
  38560. exposure: number;
  38561. /**
  38562. * Gets wether tonemapping is enabled or not.
  38563. */
  38564. /**
  38565. * Sets wether tonemapping is enabled or not
  38566. */
  38567. toneMappingEnabled: boolean;
  38568. /**
  38569. * Gets the type of tone mapping effect.
  38570. */
  38571. /**
  38572. * Sets the type of tone mapping effect.
  38573. */
  38574. toneMappingType: number;
  38575. /**
  38576. * Gets contrast used in the effect.
  38577. */
  38578. /**
  38579. * Sets contrast used in the effect.
  38580. */
  38581. contrast: number;
  38582. /**
  38583. * Gets Vignette stretch size.
  38584. */
  38585. /**
  38586. * Sets Vignette stretch size.
  38587. */
  38588. vignetteStretch: number;
  38589. /**
  38590. * Gets Vignette centre X Offset.
  38591. */
  38592. /**
  38593. * Sets Vignette centre X Offset.
  38594. */
  38595. vignetteCentreX: number;
  38596. /**
  38597. * Gets Vignette centre Y Offset.
  38598. */
  38599. /**
  38600. * Sets Vignette centre Y Offset.
  38601. */
  38602. vignetteCentreY: number;
  38603. /**
  38604. * Gets Vignette weight or intensity of the vignette effect.
  38605. */
  38606. /**
  38607. * Sets Vignette weight or intensity of the vignette effect.
  38608. */
  38609. vignetteWeight: number;
  38610. /**
  38611. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38612. * if vignetteEnabled is set to true.
  38613. */
  38614. /**
  38615. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38616. * if vignetteEnabled is set to true.
  38617. */
  38618. vignetteColor: Color4;
  38619. /**
  38620. * Gets Camera field of view used by the Vignette effect.
  38621. */
  38622. /**
  38623. * Sets Camera field of view used by the Vignette effect.
  38624. */
  38625. vignetteCameraFov: number;
  38626. /**
  38627. * Gets the vignette blend mode allowing different kind of effect.
  38628. */
  38629. /**
  38630. * Sets the vignette blend mode allowing different kind of effect.
  38631. */
  38632. vignetteBlendMode: number;
  38633. /**
  38634. * Gets wether the vignette effect is enabled.
  38635. */
  38636. /**
  38637. * Sets wether the vignette effect is enabled.
  38638. */
  38639. vignetteEnabled: boolean;
  38640. private _fromLinearSpace;
  38641. /**
  38642. * Gets wether the input of the processing is in Gamma or Linear Space.
  38643. */
  38644. /**
  38645. * Sets wether the input of the processing is in Gamma or Linear Space.
  38646. */
  38647. fromLinearSpace: boolean;
  38648. /**
  38649. * Defines cache preventing GC.
  38650. */
  38651. private _defines;
  38652. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38653. /**
  38654. * "ImageProcessingPostProcess"
  38655. * @returns "ImageProcessingPostProcess"
  38656. */
  38657. getClassName(): string;
  38658. protected _updateParameters(): void;
  38659. dispose(camera?: Camera): void;
  38660. }
  38661. }
  38662. declare module BABYLON {
  38663. /**
  38664. * Class containing static functions to help procedurally build meshes
  38665. */
  38666. export class GroundBuilder {
  38667. /**
  38668. * Creates a ground mesh
  38669. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38670. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38672. * @param name defines the name of the mesh
  38673. * @param options defines the options used to create the mesh
  38674. * @param scene defines the hosting scene
  38675. * @returns the ground mesh
  38676. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38677. */
  38678. static CreateGround(name: string, options: {
  38679. width?: number;
  38680. height?: number;
  38681. subdivisions?: number;
  38682. subdivisionsX?: number;
  38683. subdivisionsY?: number;
  38684. updatable?: boolean;
  38685. }, scene: any): Mesh;
  38686. /**
  38687. * Creates a tiled ground mesh
  38688. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38689. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38690. * * 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
  38691. * * 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
  38692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38693. * @param name defines the name of the mesh
  38694. * @param options defines the options used to create the mesh
  38695. * @param scene defines the hosting scene
  38696. * @returns the tiled ground mesh
  38697. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38698. */
  38699. static CreateTiledGround(name: string, options: {
  38700. xmin: number;
  38701. zmin: number;
  38702. xmax: number;
  38703. zmax: number;
  38704. subdivisions?: {
  38705. w: number;
  38706. h: number;
  38707. };
  38708. precision?: {
  38709. w: number;
  38710. h: number;
  38711. };
  38712. updatable?: boolean;
  38713. }, scene?: Nullable<Scene>): Mesh;
  38714. /**
  38715. * Creates a ground mesh from a height map
  38716. * * The parameter `url` sets the URL of the height map image resource.
  38717. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38718. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38719. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38720. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38721. * * 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.
  38722. * * 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).
  38723. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38725. * @param name defines the name of the mesh
  38726. * @param url defines the url to the height map
  38727. * @param options defines the options used to create the mesh
  38728. * @param scene defines the hosting scene
  38729. * @returns the ground mesh
  38730. * @see https://doc.babylonjs.com/babylon101/height_map
  38731. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38732. */
  38733. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38734. width?: number;
  38735. height?: number;
  38736. subdivisions?: number;
  38737. minHeight?: number;
  38738. maxHeight?: number;
  38739. colorFilter?: Color3;
  38740. alphaFilter?: number;
  38741. updatable?: boolean;
  38742. onReady?: (mesh: GroundMesh) => void;
  38743. }, scene?: Nullable<Scene>): GroundMesh;
  38744. }
  38745. }
  38746. declare module BABYLON {
  38747. /**
  38748. * Class containing static functions to help procedurally build meshes
  38749. */
  38750. export class TorusBuilder {
  38751. /**
  38752. * Creates a torus mesh
  38753. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38754. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38755. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38757. * * 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
  38758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38759. * @param name defines the name of the mesh
  38760. * @param options defines the options used to create the mesh
  38761. * @param scene defines the hosting scene
  38762. * @returns the torus mesh
  38763. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38764. */
  38765. static CreateTorus(name: string, options: {
  38766. diameter?: number;
  38767. thickness?: number;
  38768. tessellation?: number;
  38769. updatable?: boolean;
  38770. sideOrientation?: number;
  38771. frontUVs?: Vector4;
  38772. backUVs?: Vector4;
  38773. }, scene: any): Mesh;
  38774. }
  38775. }
  38776. declare module BABYLON {
  38777. /**
  38778. * Class containing static functions to help procedurally build meshes
  38779. */
  38780. export class CylinderBuilder {
  38781. /**
  38782. * Creates a cylinder or a cone mesh
  38783. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38784. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38785. * * 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.
  38786. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38787. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38788. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38789. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38790. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38791. * * 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).
  38792. * * 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
  38793. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38794. * * 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
  38795. * * 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.
  38796. * * If `enclose` is false, a ring surface is one element.
  38797. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38798. * * 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
  38799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38800. * * 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
  38801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38802. * @param name defines the name of the mesh
  38803. * @param options defines the options used to create the mesh
  38804. * @param scene defines the hosting scene
  38805. * @returns the cylinder mesh
  38806. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38807. */
  38808. static CreateCylinder(name: string, options: {
  38809. height?: number;
  38810. diameterTop?: number;
  38811. diameterBottom?: number;
  38812. diameter?: number;
  38813. tessellation?: number;
  38814. subdivisions?: number;
  38815. arc?: number;
  38816. faceColors?: Color4[];
  38817. faceUV?: Vector4[];
  38818. updatable?: boolean;
  38819. hasRings?: boolean;
  38820. enclose?: boolean;
  38821. sideOrientation?: number;
  38822. frontUVs?: Vector4;
  38823. backUVs?: Vector4;
  38824. }, scene: any): Mesh;
  38825. }
  38826. }
  38827. declare module BABYLON {
  38828. /**
  38829. * Manager for handling gamepads
  38830. */
  38831. export class GamepadManager {
  38832. private _scene?;
  38833. private _babylonGamepads;
  38834. private _oneGamepadConnected;
  38835. /** @hidden */ isMonitoring: boolean;
  38836. private _gamepadEventSupported;
  38837. private _gamepadSupport;
  38838. /**
  38839. * observable to be triggered when the gamepad controller has been connected
  38840. */
  38841. onGamepadConnectedObservable: Observable<Gamepad>;
  38842. /**
  38843. * observable to be triggered when the gamepad controller has been disconnected
  38844. */
  38845. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38846. private _onGamepadConnectedEvent;
  38847. private _onGamepadDisconnectedEvent;
  38848. /**
  38849. * Initializes the gamepad manager
  38850. * @param _scene BabylonJS scene
  38851. */
  38852. constructor(_scene?: Scene | undefined);
  38853. /**
  38854. * The gamepads in the game pad manager
  38855. */
  38856. readonly gamepads: Gamepad[];
  38857. /**
  38858. * Get the gamepad controllers based on type
  38859. * @param type The type of gamepad controller
  38860. * @returns Nullable gamepad
  38861. */
  38862. getGamepadByType(type?: number): Nullable<Gamepad>;
  38863. /**
  38864. * Disposes the gamepad manager
  38865. */
  38866. dispose(): void;
  38867. private _addNewGamepad;
  38868. private _startMonitoringGamepads;
  38869. private _stopMonitoringGamepads;
  38870. /** @hidden */ checkGamepadsStatus(): void;
  38871. private _updateGamepadObjects;
  38872. }
  38873. }
  38874. declare module BABYLON {
  38875. interface Scene {
  38876. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  38877. /**
  38878. * Gets the gamepad manager associated with the scene
  38879. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38880. */
  38881. gamepadManager: GamepadManager;
  38882. }
  38883. /**
  38884. * Interface representing a free camera inputs manager
  38885. */
  38886. interface FreeCameraInputsManager {
  38887. /**
  38888. * Adds gamepad input support to the FreeCameraInputsManager.
  38889. * @returns the FreeCameraInputsManager
  38890. */
  38891. addGamepad(): FreeCameraInputsManager;
  38892. }
  38893. /**
  38894. * Interface representing an arc rotate camera inputs manager
  38895. */
  38896. interface ArcRotateCameraInputsManager {
  38897. /**
  38898. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38899. * @returns the camera inputs manager
  38900. */
  38901. addGamepad(): ArcRotateCameraInputsManager;
  38902. }
  38903. /**
  38904. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38905. */
  38906. export class GamepadSystemSceneComponent implements ISceneComponent {
  38907. /**
  38908. * The component name helpfull to identify the component in the list of scene components.
  38909. */
  38910. readonly name: string;
  38911. /**
  38912. * The scene the component belongs to.
  38913. */
  38914. scene: Scene;
  38915. /**
  38916. * Creates a new instance of the component for the given scene
  38917. * @param scene Defines the scene to register the component in
  38918. */
  38919. constructor(scene: Scene);
  38920. /**
  38921. * Registers the component in a given scene
  38922. */
  38923. register(): void;
  38924. /**
  38925. * Rebuilds the elements related to this component in case of
  38926. * context lost for instance.
  38927. */
  38928. rebuild(): void;
  38929. /**
  38930. * Disposes the component and the associated ressources
  38931. */
  38932. dispose(): void;
  38933. private _beforeCameraUpdate;
  38934. }
  38935. }
  38936. declare module BABYLON {
  38937. /**
  38938. * Options to modify the vr teleportation behavior.
  38939. */
  38940. export interface VRTeleportationOptions {
  38941. /**
  38942. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38943. */
  38944. floorMeshName?: string;
  38945. /**
  38946. * A list of meshes to be used as the teleportation floor. (default: empty)
  38947. */
  38948. floorMeshes?: Mesh[];
  38949. }
  38950. /**
  38951. * Options to modify the vr experience helper's behavior.
  38952. */
  38953. export interface VRExperienceHelperOptions extends WebVROptions {
  38954. /**
  38955. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38956. */
  38957. createDeviceOrientationCamera?: boolean;
  38958. /**
  38959. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38960. */
  38961. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38962. /**
  38963. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38964. */
  38965. laserToggle?: boolean;
  38966. /**
  38967. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38968. */
  38969. floorMeshes?: Mesh[];
  38970. /**
  38971. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  38972. */
  38973. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  38974. }
  38975. /**
  38976. * Event containing information after VR has been entered
  38977. */
  38978. export class OnAfterEnteringVRObservableEvent {
  38979. /**
  38980. * If entering vr was successful
  38981. */
  38982. success: boolean;
  38983. }
  38984. /**
  38985. * Helps to quickly add VR support to an existing scene.
  38986. * See http://doc.babylonjs.com/how_to/webvr_helper
  38987. */
  38988. export class VRExperienceHelper {
  38989. /** Options to modify the vr experience helper's behavior. */
  38990. webVROptions: VRExperienceHelperOptions;
  38991. private _scene;
  38992. private _position;
  38993. private _btnVR;
  38994. private _btnVRDisplayed;
  38995. private _webVRsupported;
  38996. private _webVRready;
  38997. private _webVRrequesting;
  38998. private _webVRpresenting;
  38999. private _hasEnteredVR;
  39000. private _fullscreenVRpresenting;
  39001. private _canvas;
  39002. private _webVRCamera;
  39003. private _vrDeviceOrientationCamera;
  39004. private _deviceOrientationCamera;
  39005. private _existingCamera;
  39006. private _onKeyDown;
  39007. private _onVrDisplayPresentChange;
  39008. private _onVRDisplayChanged;
  39009. private _onVRRequestPresentStart;
  39010. private _onVRRequestPresentComplete;
  39011. /**
  39012. * Observable raised right before entering VR.
  39013. */
  39014. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39015. /**
  39016. * Observable raised when entering VR has completed.
  39017. */
  39018. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39019. /**
  39020. * Observable raised when exiting VR.
  39021. */
  39022. onExitingVRObservable: Observable<VRExperienceHelper>;
  39023. /**
  39024. * Observable raised when controller mesh is loaded.
  39025. */
  39026. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39027. /** Return this.onEnteringVRObservable
  39028. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39029. */
  39030. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39031. /** Return this.onExitingVRObservable
  39032. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39033. */
  39034. readonly onExitingVR: Observable<VRExperienceHelper>;
  39035. /** Return this.onControllerMeshLoadedObservable
  39036. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39037. */
  39038. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39039. private _rayLength;
  39040. private _useCustomVRButton;
  39041. private _teleportationRequested;
  39042. private _teleportActive;
  39043. private _floorMeshName;
  39044. private _floorMeshesCollection;
  39045. private _rotationAllowed;
  39046. private _teleportBackwardsVector;
  39047. private _teleportationTarget;
  39048. private _isDefaultTeleportationTarget;
  39049. private _postProcessMove;
  39050. private _teleportationFillColor;
  39051. private _teleportationBorderColor;
  39052. private _rotationAngle;
  39053. private _haloCenter;
  39054. private _cameraGazer;
  39055. private _padSensibilityUp;
  39056. private _padSensibilityDown;
  39057. private _leftController;
  39058. private _rightController;
  39059. /**
  39060. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39061. */
  39062. onNewMeshSelected: Observable<AbstractMesh>;
  39063. /**
  39064. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39065. */
  39066. onNewMeshPicked: Observable<PickingInfo>;
  39067. private _circleEase;
  39068. /**
  39069. * Observable raised before camera teleportation
  39070. */
  39071. onBeforeCameraTeleport: Observable<Vector3>;
  39072. /**
  39073. * Observable raised after camera teleportation
  39074. */
  39075. onAfterCameraTeleport: Observable<Vector3>;
  39076. /**
  39077. * Observable raised when current selected mesh gets unselected
  39078. */
  39079. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39080. private _raySelectionPredicate;
  39081. /**
  39082. * To be optionaly changed by user to define custom ray selection
  39083. */
  39084. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39085. /**
  39086. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39087. */
  39088. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39089. /**
  39090. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39091. */
  39092. teleportationEnabled: boolean;
  39093. private _defaultHeight;
  39094. private _teleportationInitialized;
  39095. private _interactionsEnabled;
  39096. private _interactionsRequested;
  39097. private _displayGaze;
  39098. private _displayLaserPointer;
  39099. /**
  39100. * The mesh used to display where the user is going to teleport.
  39101. */
  39102. /**
  39103. * Sets the mesh to be used to display where the user is going to teleport.
  39104. */
  39105. teleportationTarget: Mesh;
  39106. /**
  39107. * 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
  39108. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39109. * See http://doc.babylonjs.com/resources/baking_transformations
  39110. */
  39111. gazeTrackerMesh: Mesh;
  39112. /**
  39113. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39114. */
  39115. updateGazeTrackerScale: boolean;
  39116. /**
  39117. * If the gaze trackers color should be updated when selecting meshes
  39118. */
  39119. updateGazeTrackerColor: boolean;
  39120. /**
  39121. * The gaze tracking mesh corresponding to the left controller
  39122. */
  39123. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39124. /**
  39125. * The gaze tracking mesh corresponding to the right controller
  39126. */
  39127. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39128. /**
  39129. * If the ray of the gaze should be displayed.
  39130. */
  39131. /**
  39132. * Sets if the ray of the gaze should be displayed.
  39133. */
  39134. displayGaze: boolean;
  39135. /**
  39136. * If the ray of the LaserPointer should be displayed.
  39137. */
  39138. /**
  39139. * Sets if the ray of the LaserPointer should be displayed.
  39140. */
  39141. displayLaserPointer: boolean;
  39142. /**
  39143. * The deviceOrientationCamera used as the camera when not in VR.
  39144. */
  39145. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39146. /**
  39147. * Based on the current WebVR support, returns the current VR camera used.
  39148. */
  39149. readonly currentVRCamera: Nullable<Camera>;
  39150. /**
  39151. * The webVRCamera which is used when in VR.
  39152. */
  39153. readonly webVRCamera: WebVRFreeCamera;
  39154. /**
  39155. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39156. */
  39157. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39158. private readonly _teleportationRequestInitiated;
  39159. /**
  39160. * Defines wether or not Pointer lock should be requested when switching to
  39161. * full screen.
  39162. */
  39163. requestPointerLockOnFullScreen: boolean;
  39164. /**
  39165. * Instantiates a VRExperienceHelper.
  39166. * Helps to quickly add VR support to an existing scene.
  39167. * @param scene The scene the VRExperienceHelper belongs to.
  39168. * @param webVROptions Options to modify the vr experience helper's behavior.
  39169. */
  39170. constructor(scene: Scene,
  39171. /** Options to modify the vr experience helper's behavior. */
  39172. webVROptions?: VRExperienceHelperOptions);
  39173. private _onDefaultMeshLoaded;
  39174. private _onResize;
  39175. private _onFullscreenChange;
  39176. /**
  39177. * Gets a value indicating if we are currently in VR mode.
  39178. */
  39179. readonly isInVRMode: boolean;
  39180. private onVrDisplayPresentChange;
  39181. private onVRDisplayChanged;
  39182. private moveButtonToBottomRight;
  39183. private displayVRButton;
  39184. private updateButtonVisibility;
  39185. private _cachedAngularSensibility;
  39186. /**
  39187. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39188. * Otherwise, will use the fullscreen API.
  39189. */
  39190. enterVR(): void;
  39191. /**
  39192. * Attempt to exit VR, or fullscreen.
  39193. */
  39194. exitVR(): void;
  39195. /**
  39196. * The position of the vr experience helper.
  39197. */
  39198. /**
  39199. * Sets the position of the vr experience helper.
  39200. */
  39201. position: Vector3;
  39202. /**
  39203. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39204. */
  39205. enableInteractions(): void;
  39206. private readonly _noControllerIsActive;
  39207. private beforeRender;
  39208. private _isTeleportationFloor;
  39209. /**
  39210. * Adds a floor mesh to be used for teleportation.
  39211. * @param floorMesh the mesh to be used for teleportation.
  39212. */
  39213. addFloorMesh(floorMesh: Mesh): void;
  39214. /**
  39215. * Removes a floor mesh from being used for teleportation.
  39216. * @param floorMesh the mesh to be removed.
  39217. */
  39218. removeFloorMesh(floorMesh: Mesh): void;
  39219. /**
  39220. * Enables interactions and teleportation using the VR controllers and gaze.
  39221. * @param vrTeleportationOptions options to modify teleportation behavior.
  39222. */
  39223. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39224. private _onNewGamepadConnected;
  39225. private _tryEnableInteractionOnController;
  39226. private _onNewGamepadDisconnected;
  39227. private _enableInteractionOnController;
  39228. private _checkTeleportWithRay;
  39229. private _checkRotate;
  39230. private _checkTeleportBackwards;
  39231. private _enableTeleportationOnController;
  39232. private _createTeleportationCircles;
  39233. private _displayTeleportationTarget;
  39234. private _hideTeleportationTarget;
  39235. private _rotateCamera;
  39236. private _moveTeleportationSelectorTo;
  39237. private _workingVector;
  39238. private _workingQuaternion;
  39239. private _workingMatrix;
  39240. /**
  39241. * Teleports the users feet to the desired location
  39242. * @param location The location where the user's feet should be placed
  39243. */
  39244. teleportCamera(location: Vector3): void;
  39245. private _convertNormalToDirectionOfRay;
  39246. private _castRayAndSelectObject;
  39247. private _notifySelectedMeshUnselected;
  39248. /**
  39249. * Sets the color of the laser ray from the vr controllers.
  39250. * @param color new color for the ray.
  39251. */
  39252. changeLaserColor(color: Color3): void;
  39253. /**
  39254. * Sets the color of the ray from the vr headsets gaze.
  39255. * @param color new color for the ray.
  39256. */
  39257. changeGazeColor(color: Color3): void;
  39258. /**
  39259. * Exits VR and disposes of the vr experience helper
  39260. */
  39261. dispose(): void;
  39262. /**
  39263. * Gets the name of the VRExperienceHelper class
  39264. * @returns "VRExperienceHelper"
  39265. */
  39266. getClassName(): string;
  39267. }
  39268. }
  39269. declare module BABYLON {
  39270. /**
  39271. * Manages an XRSession
  39272. * @see https://doc.babylonjs.com/how_to/webxr
  39273. */
  39274. export class WebXRSessionManager implements IDisposable {
  39275. private scene;
  39276. /**
  39277. * Fires every time a new xrFrame arrives which can be used to update the camera
  39278. */
  39279. onXRFrameObservable: Observable<any>;
  39280. /**
  39281. * Fires when the xr session is ended either by the device or manually done
  39282. */
  39283. onXRSessionEnded: Observable<any>;
  39284. /** @hidden */ xrSession: XRSession;
  39285. /** @hidden */ frameOfReference: XRFrameOfReference;
  39286. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39287. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  39288. private _xrNavigator;
  39289. private _xrDevice;
  39290. private _tmpMatrix;
  39291. /**
  39292. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39293. * @param scene The scene which the session should be created for
  39294. */
  39295. constructor(scene: Scene);
  39296. /**
  39297. * Initializes the manager
  39298. * After initialization enterXR can be called to start an XR session
  39299. * @returns Promise which resolves after it is initialized
  39300. */
  39301. initializeAsync(): Promise<void>;
  39302. /**
  39303. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39304. * @param sessionCreationOptions xr options to create the session with
  39305. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39306. * @returns Promise which resolves after it enters XR
  39307. */
  39308. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39309. /**
  39310. * Stops the xrSession and restores the renderloop
  39311. * @returns Promise which resolves after it exits XR
  39312. */
  39313. exitXRAsync(): Promise<void>;
  39314. /**
  39315. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39316. * @param ray ray to cast into the environment
  39317. * @returns Promise which resolves with a collision point in the environment if it exists
  39318. */
  39319. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39320. /**
  39321. * Checks if a session would be supported for the creation options specified
  39322. * @param options creation options to check if they are supported
  39323. * @returns true if supported
  39324. */
  39325. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39326. /**
  39327. * @hidden
  39328. * Converts the render layer of xrSession to a render target
  39329. * @param session session to create render target for
  39330. * @param scene scene the new render target should be created for
  39331. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39332. /**
  39333. * Disposes of the session manager
  39334. */
  39335. dispose(): void;
  39336. }
  39337. }
  39338. declare module BABYLON {
  39339. /**
  39340. * WebXR Camera which holds the views for the xrSession
  39341. * @see https://doc.babylonjs.com/how_to/webxr
  39342. */
  39343. export class WebXRCamera extends FreeCamera {
  39344. private static _TmpMatrix;
  39345. /**
  39346. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39347. * @param name the name of the camera
  39348. * @param scene the scene to add the camera to
  39349. */
  39350. constructor(name: string, scene: Scene);
  39351. private _updateNumberOfRigCameras;
  39352. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  39353. /**
  39354. * Updates the cameras position from the current pose information of the XR session
  39355. * @param xrSessionManager the session containing pose information
  39356. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39357. */
  39358. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39359. }
  39360. }
  39361. declare module BABYLON {
  39362. /**
  39363. * States of the webXR experience
  39364. */
  39365. export enum WebXRState {
  39366. /**
  39367. * Transitioning to being in XR mode
  39368. */
  39369. ENTERING_XR = 0,
  39370. /**
  39371. * Transitioning to non XR mode
  39372. */
  39373. EXITING_XR = 1,
  39374. /**
  39375. * In XR mode and presenting
  39376. */
  39377. IN_XR = 2,
  39378. /**
  39379. * Not entered XR mode
  39380. */
  39381. NOT_IN_XR = 3
  39382. }
  39383. /**
  39384. * Helper class used to enable XR
  39385. * @see https://doc.babylonjs.com/how_to/webxr
  39386. */
  39387. export class WebXRExperienceHelper implements IDisposable {
  39388. private scene;
  39389. /**
  39390. * 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
  39391. */
  39392. container: AbstractMesh;
  39393. /**
  39394. * Camera used to render xr content
  39395. */
  39396. camera: WebXRCamera;
  39397. /**
  39398. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39399. */
  39400. state: WebXRState;
  39401. private _setState;
  39402. private static _TmpVector;
  39403. /**
  39404. * Fires when the state of the experience helper has changed
  39405. */
  39406. onStateChangedObservable: Observable<WebXRState>;
  39407. /** @hidden */ sessionManager: WebXRSessionManager;
  39408. private _nonVRCamera;
  39409. private _originalSceneAutoClear;
  39410. private _supported;
  39411. /**
  39412. * Creates the experience helper
  39413. * @param scene the scene to attach the experience helper to
  39414. * @returns a promise for the experience helper
  39415. */
  39416. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39417. /**
  39418. * Creates a WebXRExperienceHelper
  39419. * @param scene The scene the helper should be created in
  39420. */
  39421. private constructor();
  39422. /**
  39423. * Exits XR mode and returns the scene to its original state
  39424. * @returns promise that resolves after xr mode has exited
  39425. */
  39426. exitXRAsync(): Promise<void>;
  39427. /**
  39428. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39429. * @param sessionCreationOptions options for the XR session
  39430. * @param frameOfReference frame of reference of the XR session
  39431. * @returns promise that resolves after xr mode has entered
  39432. */
  39433. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39434. /**
  39435. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39436. * @param ray ray to cast into the environment
  39437. * @returns Promise which resolves with a collision point in the environment if it exists
  39438. */
  39439. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39440. /**
  39441. * Updates the global position of the camera by moving the camera's container
  39442. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39443. * @param position The desired global position of the camera
  39444. */
  39445. setPositionOfCameraUsingContainer(position: Vector3): void;
  39446. /**
  39447. * Rotates the xr camera by rotating the camera's container around the camera's position
  39448. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39449. * @param rotation the desired quaternion rotation to apply to the camera
  39450. */
  39451. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39452. /**
  39453. * Checks if the creation options are supported by the xr session
  39454. * @param options creation options
  39455. * @returns true if supported
  39456. */
  39457. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39458. /**
  39459. * Disposes of the experience helper
  39460. */
  39461. dispose(): void;
  39462. }
  39463. }
  39464. declare module BABYLON {
  39465. /**
  39466. * Button which can be used to enter a different mode of XR
  39467. */
  39468. export class WebXREnterExitUIButton {
  39469. /** button element */
  39470. element: HTMLElement;
  39471. /** XR initialization options for the button */
  39472. initializationOptions: XRSessionCreationOptions;
  39473. /**
  39474. * Creates a WebXREnterExitUIButton
  39475. * @param element button element
  39476. * @param initializationOptions XR initialization options for the button
  39477. */
  39478. constructor(
  39479. /** button element */
  39480. element: HTMLElement,
  39481. /** XR initialization options for the button */
  39482. initializationOptions: XRSessionCreationOptions);
  39483. /**
  39484. * Overwritable function which can be used to update the button's visuals when the state changes
  39485. * @param activeButton the current active button in the UI
  39486. */
  39487. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39488. }
  39489. /**
  39490. * Options to create the webXR UI
  39491. */
  39492. export class WebXREnterExitUIOptions {
  39493. /**
  39494. * Context to enter xr with
  39495. */
  39496. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39497. /**
  39498. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39499. */
  39500. customButtons?: Array<WebXREnterExitUIButton>;
  39501. }
  39502. /**
  39503. * UI to allow the user to enter/exit XR mode
  39504. */
  39505. export class WebXREnterExitUI implements IDisposable {
  39506. private scene;
  39507. private _overlay;
  39508. private _buttons;
  39509. private _activeButton;
  39510. /**
  39511. * Fired every time the active button is changed.
  39512. *
  39513. * When xr is entered via a button that launches xr that button will be the callback parameter
  39514. *
  39515. * When exiting xr the callback parameter will be null)
  39516. */
  39517. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39518. /**
  39519. * Creates UI to allow the user to enter/exit XR mode
  39520. * @param scene the scene to add the ui to
  39521. * @param helper the xr experience helper to enter/exit xr with
  39522. * @param options options to configure the UI
  39523. * @returns the created ui
  39524. */
  39525. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39526. private constructor();
  39527. private _updateButtons;
  39528. /**
  39529. * Disposes of the object
  39530. */
  39531. dispose(): void;
  39532. }
  39533. }
  39534. declare module BABYLON {
  39535. /**
  39536. * Represents an XR input
  39537. */
  39538. export class WebXRController {
  39539. /**
  39540. * 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
  39541. */
  39542. grip?: AbstractMesh;
  39543. /**
  39544. * Pointer which can be used to select objects or attach a visible laser to
  39545. */
  39546. pointer: AbstractMesh;
  39547. /**
  39548. * Creates the controller
  39549. * @see https://doc.babylonjs.com/how_to/webxr
  39550. * @param scene the scene which the controller should be associated to
  39551. */
  39552. constructor(scene: Scene);
  39553. /**
  39554. * Disposes of the object
  39555. */
  39556. dispose(): void;
  39557. }
  39558. /**
  39559. * XR input used to track XR inputs such as controllers/rays
  39560. */
  39561. export class WebXRInput implements IDisposable {
  39562. private helper;
  39563. /**
  39564. * XR controllers being tracked
  39565. */
  39566. controllers: Array<WebXRController>;
  39567. private _tmpMatrix;
  39568. private _frameObserver;
  39569. /**
  39570. * Initializes the WebXRInput
  39571. * @param helper experience helper which the input should be created for
  39572. */
  39573. constructor(helper: WebXRExperienceHelper);
  39574. /**
  39575. * Disposes of the object
  39576. */
  39577. dispose(): void;
  39578. }
  39579. }
  39580. declare module BABYLON {
  39581. /**
  39582. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39583. */
  39584. export class WebXRManagedOutputCanvas implements IDisposable {
  39585. private _canvas;
  39586. /**
  39587. * xrpresent context of the canvas which can be used to display/mirror xr content
  39588. */
  39589. canvasContext: Nullable<WebGLRenderingContext>;
  39590. /**
  39591. * Initializes the canvas to be added/removed upon entering/exiting xr
  39592. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39593. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39594. */
  39595. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39596. /**
  39597. * Disposes of the object
  39598. */
  39599. dispose(): void;
  39600. private _setManagedOutputCanvas;
  39601. private _addCanvas;
  39602. private _removeCanvas;
  39603. }
  39604. }
  39605. declare module BABYLON {
  39606. /**
  39607. * Contains an array of blocks representing the octree
  39608. */
  39609. export interface IOctreeContainer<T> {
  39610. /**
  39611. * Blocks within the octree
  39612. */
  39613. blocks: Array<OctreeBlock<T>>;
  39614. }
  39615. /**
  39616. * Class used to store a cell in an octree
  39617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39618. */
  39619. export class OctreeBlock<T> {
  39620. /**
  39621. * Gets the content of the current block
  39622. */
  39623. entries: T[];
  39624. /**
  39625. * Gets the list of block children
  39626. */
  39627. blocks: Array<OctreeBlock<T>>;
  39628. private _depth;
  39629. private _maxDepth;
  39630. private _capacity;
  39631. private _minPoint;
  39632. private _maxPoint;
  39633. private _boundingVectors;
  39634. private _creationFunc;
  39635. /**
  39636. * Creates a new block
  39637. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39638. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39639. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39640. * @param depth defines the current depth of this block in the octree
  39641. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39642. * @param creationFunc defines a callback to call when an element is added to the block
  39643. */
  39644. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39645. /**
  39646. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39647. */
  39648. readonly capacity: number;
  39649. /**
  39650. * Gets the minimum vector (in world space) of the block's bounding box
  39651. */
  39652. readonly minPoint: Vector3;
  39653. /**
  39654. * Gets the maximum vector (in world space) of the block's bounding box
  39655. */
  39656. readonly maxPoint: Vector3;
  39657. /**
  39658. * Add a new element to this block
  39659. * @param entry defines the element to add
  39660. */
  39661. addEntry(entry: T): void;
  39662. /**
  39663. * Remove an element from this block
  39664. * @param entry defines the element to remove
  39665. */
  39666. removeEntry(entry: T): void;
  39667. /**
  39668. * Add an array of elements to this block
  39669. * @param entries defines the array of elements to add
  39670. */
  39671. addEntries(entries: T[]): void;
  39672. /**
  39673. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39674. * @param frustumPlanes defines the frustum planes to test
  39675. * @param selection defines the array to store current content if selection is positive
  39676. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39677. */
  39678. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39679. /**
  39680. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39681. * @param sphereCenter defines the bounding sphere center
  39682. * @param sphereRadius defines the bounding sphere radius
  39683. * @param selection defines the array to store current content if selection is positive
  39684. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39685. */
  39686. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39687. /**
  39688. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39689. * @param ray defines the ray to test with
  39690. * @param selection defines the array to store current content if selection is positive
  39691. */
  39692. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39693. /**
  39694. * Subdivide the content into child blocks (this block will then be empty)
  39695. */
  39696. createInnerBlocks(): void;
  39697. /**
  39698. * @hidden
  39699. */ 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;
  39700. }
  39701. }
  39702. declare module BABYLON {
  39703. /**
  39704. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39705. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39706. */
  39707. export class Octree<T> {
  39708. /** 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.) */
  39709. maxDepth: number;
  39710. /**
  39711. * Blocks within the octree containing objects
  39712. */
  39713. blocks: Array<OctreeBlock<T>>;
  39714. /**
  39715. * Content stored in the octree
  39716. */
  39717. dynamicContent: T[];
  39718. private _maxBlockCapacity;
  39719. private _selectionContent;
  39720. private _creationFunc;
  39721. /**
  39722. * Creates a octree
  39723. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39724. * @param creationFunc function to be used to instatiate the octree
  39725. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39726. * @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.)
  39727. */
  39728. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39729. /** 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.) */
  39730. maxDepth?: number);
  39731. /**
  39732. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39733. * @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);
  39734. * @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);
  39735. * @param entries meshes to be added to the octree blocks
  39736. */
  39737. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39738. /**
  39739. * Adds a mesh to the octree
  39740. * @param entry Mesh to add to the octree
  39741. */
  39742. addMesh(entry: T): void;
  39743. /**
  39744. * Remove an element from the octree
  39745. * @param entry defines the element to remove
  39746. */
  39747. removeMesh(entry: T): void;
  39748. /**
  39749. * Selects an array of meshes within the frustum
  39750. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39751. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39752. * @returns array of meshes within the frustum
  39753. */
  39754. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39755. /**
  39756. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39757. * @param sphereCenter defines the bounding sphere center
  39758. * @param sphereRadius defines the bounding sphere radius
  39759. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39760. * @returns an array of objects that intersect the sphere
  39761. */
  39762. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39763. /**
  39764. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39765. * @param ray defines the ray to test with
  39766. * @returns array of intersected objects
  39767. */
  39768. intersectsRay(ray: Ray): SmartArray<T>;
  39769. /**
  39770. * Adds a mesh into the octree block if it intersects the block
  39771. */
  39772. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39773. /**
  39774. * Adds a submesh into the octree block if it intersects the block
  39775. */
  39776. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39777. }
  39778. }
  39779. declare module BABYLON {
  39780. interface Scene {
  39781. /**
  39782. * @hidden
  39783. * Backing Filed
  39784. */ selectionOctree: Octree<AbstractMesh>;
  39785. /**
  39786. * Gets the octree used to boost mesh selection (picking)
  39787. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39788. */
  39789. selectionOctree: Octree<AbstractMesh>;
  39790. /**
  39791. * Creates or updates the octree used to boost selection (picking)
  39792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39793. * @param maxCapacity defines the maximum capacity per leaf
  39794. * @param maxDepth defines the maximum depth of the octree
  39795. * @returns an octree of AbstractMesh
  39796. */
  39797. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39798. }
  39799. interface AbstractMesh {
  39800. /**
  39801. * @hidden
  39802. * Backing Field
  39803. */ submeshesOctree: Octree<SubMesh>;
  39804. /**
  39805. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39806. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39807. * @param maxCapacity defines the maximum size of each block (64 by default)
  39808. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39809. * @returns the new octree
  39810. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39811. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39812. */
  39813. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39814. }
  39815. /**
  39816. * Defines the octree scene component responsible to manage any octrees
  39817. * in a given scene.
  39818. */
  39819. export class OctreeSceneComponent {
  39820. /**
  39821. * The component name help to identify the component in the list of scene components.
  39822. */
  39823. readonly name: string;
  39824. /**
  39825. * The scene the component belongs to.
  39826. */
  39827. scene: Scene;
  39828. /**
  39829. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39830. */
  39831. readonly checksIsEnabled: boolean;
  39832. /**
  39833. * Creates a new instance of the component for the given scene
  39834. * @param scene Defines the scene to register the component in
  39835. */
  39836. constructor(scene: Scene);
  39837. /**
  39838. * Registers the component in a given scene
  39839. */
  39840. register(): void;
  39841. /**
  39842. * Return the list of active meshes
  39843. * @returns the list of active meshes
  39844. */
  39845. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39846. /**
  39847. * Return the list of active sub meshes
  39848. * @param mesh The mesh to get the candidates sub meshes from
  39849. * @returns the list of active sub meshes
  39850. */
  39851. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39852. private _tempRay;
  39853. /**
  39854. * Return the list of sub meshes intersecting with a given local ray
  39855. * @param mesh defines the mesh to find the submesh for
  39856. * @param localRay defines the ray in local space
  39857. * @returns the list of intersecting sub meshes
  39858. */
  39859. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39860. /**
  39861. * Return the list of sub meshes colliding with a collider
  39862. * @param mesh defines the mesh to find the submesh for
  39863. * @param collider defines the collider to evaluate the collision against
  39864. * @returns the list of colliding sub meshes
  39865. */
  39866. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39867. /**
  39868. * Rebuilds the elements related to this component in case of
  39869. * context lost for instance.
  39870. */
  39871. rebuild(): void;
  39872. /**
  39873. * Disposes the component and the associated ressources.
  39874. */
  39875. dispose(): void;
  39876. }
  39877. }
  39878. declare module BABYLON {
  39879. /**
  39880. * Renders a layer on top of an existing scene
  39881. */
  39882. export class UtilityLayerRenderer implements IDisposable {
  39883. /** the original scene that will be rendered on top of */
  39884. originalScene: Scene;
  39885. private _pointerCaptures;
  39886. private _lastPointerEvents;
  39887. private static _DefaultUtilityLayer;
  39888. private static _DefaultKeepDepthUtilityLayer;
  39889. private _sharedGizmoLight;
  39890. /**
  39891. * @hidden
  39892. * Light which used by gizmos to get light shading
  39893. */ getSharedGizmoLight(): HemisphericLight;
  39894. /**
  39895. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39896. */
  39897. pickUtilitySceneFirst: boolean;
  39898. /**
  39899. * 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)
  39900. */
  39901. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39902. /**
  39903. * 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)
  39904. */
  39905. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39906. /**
  39907. * The scene that is rendered on top of the original scene
  39908. */
  39909. utilityLayerScene: Scene;
  39910. /**
  39911. * If the utility layer should automatically be rendered on top of existing scene
  39912. */
  39913. shouldRender: boolean;
  39914. /**
  39915. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39916. */
  39917. onlyCheckPointerDownEvents: boolean;
  39918. /**
  39919. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39920. */
  39921. processAllEvents: boolean;
  39922. /**
  39923. * Observable raised when the pointer move from the utility layer scene to the main scene
  39924. */
  39925. onPointerOutObservable: Observable<number>;
  39926. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39927. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39928. private _afterRenderObserver;
  39929. private _sceneDisposeObserver;
  39930. private _originalPointerObserver;
  39931. /**
  39932. * Instantiates a UtilityLayerRenderer
  39933. * @param originalScene the original scene that will be rendered on top of
  39934. * @param handleEvents boolean indicating if the utility layer should handle events
  39935. */
  39936. constructor(
  39937. /** the original scene that will be rendered on top of */
  39938. originalScene: Scene, handleEvents?: boolean);
  39939. private _notifyObservers;
  39940. /**
  39941. * Renders the utility layers scene on top of the original scene
  39942. */
  39943. render(): void;
  39944. /**
  39945. * Disposes of the renderer
  39946. */
  39947. dispose(): void;
  39948. private _updateCamera;
  39949. }
  39950. }
  39951. declare module BABYLON {
  39952. /**
  39953. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39954. */
  39955. export class Gizmo implements IDisposable {
  39956. /** The utility layer the gizmo will be added to */
  39957. gizmoLayer: UtilityLayerRenderer;
  39958. /**
  39959. * The root mesh of the gizmo
  39960. */ rootMesh: Mesh;
  39961. private _attachedMesh;
  39962. /**
  39963. * Ratio for the scale of the gizmo (Default: 1)
  39964. */
  39965. scaleRatio: number;
  39966. /**
  39967. * If a custom mesh has been set (Default: false)
  39968. */
  39969. protected _customMeshSet: boolean;
  39970. /**
  39971. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39972. * * When set, interactions will be enabled
  39973. */
  39974. attachedMesh: Nullable<AbstractMesh>;
  39975. /**
  39976. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39977. * @param mesh The mesh to replace the default mesh of the gizmo
  39978. */
  39979. setCustomMesh(mesh: Mesh): void;
  39980. /**
  39981. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39982. */
  39983. updateGizmoRotationToMatchAttachedMesh: boolean;
  39984. /**
  39985. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39986. */
  39987. updateGizmoPositionToMatchAttachedMesh: boolean;
  39988. /**
  39989. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39990. */
  39991. protected _updateScale: boolean;
  39992. protected _interactionsEnabled: boolean;
  39993. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39994. private _beforeRenderObserver;
  39995. private _tempVector;
  39996. /**
  39997. * Creates a gizmo
  39998. * @param gizmoLayer The utility layer the gizmo will be added to
  39999. */
  40000. constructor(
  40001. /** The utility layer the gizmo will be added to */
  40002. gizmoLayer?: UtilityLayerRenderer);
  40003. /**
  40004. * Updates the gizmo to match the attached mesh's position/rotation
  40005. */
  40006. protected _update(): void;
  40007. /**
  40008. * Disposes of the gizmo
  40009. */
  40010. dispose(): void;
  40011. }
  40012. }
  40013. declare module BABYLON {
  40014. /**
  40015. * Single axis drag gizmo
  40016. */
  40017. export class AxisDragGizmo extends Gizmo {
  40018. /**
  40019. * Drag behavior responsible for the gizmos dragging interactions
  40020. */
  40021. dragBehavior: PointerDragBehavior;
  40022. private _pointerObserver;
  40023. /**
  40024. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40025. */
  40026. snapDistance: number;
  40027. /**
  40028. * Event that fires each time the gizmo snaps to a new location.
  40029. * * snapDistance is the the change in distance
  40030. */
  40031. onSnapObservable: Observable<{
  40032. snapDistance: number;
  40033. }>;
  40034. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40035. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40036. /**
  40037. * Creates an AxisDragGizmo
  40038. * @param gizmoLayer The utility layer the gizmo will be added to
  40039. * @param dragAxis The axis which the gizmo will be able to drag on
  40040. * @param color The color of the gizmo
  40041. */
  40042. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40043. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40044. /**
  40045. * Disposes of the gizmo
  40046. */
  40047. dispose(): void;
  40048. }
  40049. }
  40050. declare module BABYLON.Debug {
  40051. /**
  40052. * The Axes viewer will show 3 axes in a specific point in space
  40053. */
  40054. export class AxesViewer {
  40055. private _xAxis;
  40056. private _yAxis;
  40057. private _zAxis;
  40058. private _scaleLinesFactor;
  40059. private _instanced;
  40060. /**
  40061. * Gets the hosting scene
  40062. */
  40063. scene: Scene;
  40064. /**
  40065. * Gets or sets a number used to scale line length
  40066. */
  40067. scaleLines: number;
  40068. /** Gets the node hierarchy used to render x-axis */
  40069. readonly xAxis: TransformNode;
  40070. /** Gets the node hierarchy used to render y-axis */
  40071. readonly yAxis: TransformNode;
  40072. /** Gets the node hierarchy used to render z-axis */
  40073. readonly zAxis: TransformNode;
  40074. /**
  40075. * Creates a new AxesViewer
  40076. * @param scene defines the hosting scene
  40077. * @param scaleLines defines a number used to scale line length (1 by default)
  40078. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40079. * @param xAxis defines the node hierarchy used to render the x-axis
  40080. * @param yAxis defines the node hierarchy used to render the y-axis
  40081. * @param zAxis defines the node hierarchy used to render the z-axis
  40082. */
  40083. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40084. /**
  40085. * Force the viewer to update
  40086. * @param position defines the position of the viewer
  40087. * @param xaxis defines the x axis of the viewer
  40088. * @param yaxis defines the y axis of the viewer
  40089. * @param zaxis defines the z axis of the viewer
  40090. */
  40091. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40092. /**
  40093. * Creates an instance of this axes viewer.
  40094. * @returns a new axes viewer with instanced meshes
  40095. */
  40096. createInstance(): AxesViewer;
  40097. /** Releases resources */
  40098. dispose(): void;
  40099. private static _SetRenderingGroupId;
  40100. }
  40101. }
  40102. declare module BABYLON.Debug {
  40103. /**
  40104. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40105. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40106. */
  40107. export class BoneAxesViewer extends AxesViewer {
  40108. /**
  40109. * Gets or sets the target mesh where to display the axes viewer
  40110. */
  40111. mesh: Nullable<Mesh>;
  40112. /**
  40113. * Gets or sets the target bone where to display the axes viewer
  40114. */
  40115. bone: Nullable<Bone>;
  40116. /** Gets current position */
  40117. pos: Vector3;
  40118. /** Gets direction of X axis */
  40119. xaxis: Vector3;
  40120. /** Gets direction of Y axis */
  40121. yaxis: Vector3;
  40122. /** Gets direction of Z axis */
  40123. zaxis: Vector3;
  40124. /**
  40125. * Creates a new BoneAxesViewer
  40126. * @param scene defines the hosting scene
  40127. * @param bone defines the target bone
  40128. * @param mesh defines the target mesh
  40129. * @param scaleLines defines a scaling factor for line length (1 by default)
  40130. */
  40131. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40132. /**
  40133. * Force the viewer to update
  40134. */
  40135. update(): void;
  40136. /** Releases resources */
  40137. dispose(): void;
  40138. }
  40139. }
  40140. declare module BABYLON {
  40141. /**
  40142. * Interface used to define scene explorer extensibility option
  40143. */
  40144. export interface IExplorerExtensibilityOption {
  40145. /**
  40146. * Define the option label
  40147. */
  40148. label: string;
  40149. /**
  40150. * Defines the action to execute on click
  40151. */
  40152. action: (entity: any) => void;
  40153. }
  40154. /**
  40155. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40156. */
  40157. export interface IExplorerExtensibilityGroup {
  40158. /**
  40159. * Defines a predicate to test if a given type mut be extended
  40160. */
  40161. predicate: (entity: any) => boolean;
  40162. /**
  40163. * Gets the list of options added to a type
  40164. */
  40165. entries: IExplorerExtensibilityOption[];
  40166. }
  40167. /**
  40168. * Interface used to define the options to use to create the Inspector
  40169. */
  40170. export interface IInspectorOptions {
  40171. /**
  40172. * Display in overlay mode (default: false)
  40173. */
  40174. overlay?: boolean;
  40175. /**
  40176. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40177. */
  40178. globalRoot?: HTMLElement;
  40179. /**
  40180. * Display the Scene explorer
  40181. */
  40182. showExplorer?: boolean;
  40183. /**
  40184. * Display the property inspector
  40185. */
  40186. showInspector?: boolean;
  40187. /**
  40188. * Display in embed mode (both panes on the right)
  40189. */
  40190. embedMode?: boolean;
  40191. /**
  40192. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40193. */
  40194. handleResize?: boolean;
  40195. /**
  40196. * Allow the panes to popup (default: true)
  40197. */
  40198. enablePopup?: boolean;
  40199. /**
  40200. * Allow the panes to be closed by users (default: true)
  40201. */
  40202. enableClose?: boolean;
  40203. /**
  40204. * Optional list of extensibility entries
  40205. */
  40206. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40207. /**
  40208. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40209. */
  40210. inspectorURL?: string;
  40211. }
  40212. interface Scene {
  40213. /**
  40214. * @hidden
  40215. * Backing field
  40216. */ debugLayer: DebugLayer;
  40217. /**
  40218. * Gets the debug layer (aka Inspector) associated with the scene
  40219. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40220. */
  40221. debugLayer: DebugLayer;
  40222. }
  40223. /**
  40224. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40225. * what is happening in your scene
  40226. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40227. */
  40228. export class DebugLayer {
  40229. /**
  40230. * Define the url to get the inspector script from.
  40231. * By default it uses the babylonjs CDN.
  40232. * @ignoreNaming
  40233. */
  40234. static InspectorURL: string;
  40235. private _scene;
  40236. private BJSINSPECTOR;
  40237. /**
  40238. * Observable triggered when a property is changed through the inspector.
  40239. */
  40240. onPropertyChangedObservable: Observable<{
  40241. object: any;
  40242. property: string;
  40243. value: any;
  40244. initialValue: any;
  40245. }>;
  40246. /**
  40247. * Instantiates a new debug layer.
  40248. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40249. * what is happening in your scene
  40250. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40251. * @param scene Defines the scene to inspect
  40252. */
  40253. constructor(scene: Scene);
  40254. /** Creates the inspector window. */
  40255. private _createInspector;
  40256. /**
  40257. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40258. * @param entity defines the entity to select
  40259. * @param lineContainerTitle defines the specific block to highlight
  40260. */
  40261. select(entity: any, lineContainerTitle?: string): void;
  40262. /** Get the inspector from bundle or global */
  40263. private _getGlobalInspector;
  40264. /**
  40265. * Get if the inspector is visible or not.
  40266. * @returns true if visible otherwise, false
  40267. */
  40268. isVisible(): boolean;
  40269. /**
  40270. * Hide the inspector and close its window.
  40271. */
  40272. hide(): void;
  40273. /**
  40274. * Launch the debugLayer.
  40275. * @param config Define the configuration of the inspector
  40276. * @return a promise fulfilled when the debug layer is visible
  40277. */
  40278. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40279. }
  40280. }
  40281. declare module BABYLON {
  40282. /**
  40283. * Class containing static functions to help procedurally build meshes
  40284. */
  40285. export class BoxBuilder {
  40286. /**
  40287. * Creates a box mesh
  40288. * * The parameter `size` sets the size (float) of each box side (default 1)
  40289. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40290. * * 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)
  40291. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40293. * * 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
  40294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40295. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40296. * @param name defines the name of the mesh
  40297. * @param options defines the options used to create the mesh
  40298. * @param scene defines the hosting scene
  40299. * @returns the box mesh
  40300. */
  40301. static CreateBox(name: string, options: {
  40302. size?: number;
  40303. width?: number;
  40304. height?: number;
  40305. depth?: number;
  40306. faceUV?: Vector4[];
  40307. faceColors?: Color4[];
  40308. sideOrientation?: number;
  40309. frontUVs?: Vector4;
  40310. backUVs?: Vector4;
  40311. wrap?: boolean;
  40312. topBaseAt?: number;
  40313. bottomBaseAt?: number;
  40314. updatable?: boolean;
  40315. }, scene?: Nullable<Scene>): Mesh;
  40316. }
  40317. }
  40318. declare module BABYLON {
  40319. /**
  40320. * Class containing static functions to help procedurally build meshes
  40321. */
  40322. export class SphereBuilder {
  40323. /**
  40324. * Creates a sphere mesh
  40325. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40326. * * 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`)
  40327. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40328. * * 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
  40329. * * 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)
  40330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40331. * * 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
  40332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40333. * @param name defines the name of the mesh
  40334. * @param options defines the options used to create the mesh
  40335. * @param scene defines the hosting scene
  40336. * @returns the sphere mesh
  40337. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40338. */
  40339. static CreateSphere(name: string, options: {
  40340. segments?: number;
  40341. diameter?: number;
  40342. diameterX?: number;
  40343. diameterY?: number;
  40344. diameterZ?: number;
  40345. arc?: number;
  40346. slice?: number;
  40347. sideOrientation?: number;
  40348. frontUVs?: Vector4;
  40349. backUVs?: Vector4;
  40350. updatable?: boolean;
  40351. }, scene: any): Mesh;
  40352. }
  40353. }
  40354. declare module BABYLON.Debug {
  40355. /**
  40356. * Used to show the physics impostor around the specific mesh
  40357. */
  40358. export class PhysicsViewer {
  40359. /** @hidden */
  40360. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40361. /** @hidden */
  40362. protected _meshes: Array<Nullable<AbstractMesh>>;
  40363. /** @hidden */
  40364. protected _scene: Nullable<Scene>;
  40365. /** @hidden */
  40366. protected _numMeshes: number;
  40367. /** @hidden */
  40368. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40369. private _renderFunction;
  40370. private _utilityLayer;
  40371. private _debugBoxMesh;
  40372. private _debugSphereMesh;
  40373. private _debugCylinderMesh;
  40374. private _debugMaterial;
  40375. private _debugMeshMeshes;
  40376. /**
  40377. * Creates a new PhysicsViewer
  40378. * @param scene defines the hosting scene
  40379. */
  40380. constructor(scene: Scene);
  40381. /** @hidden */
  40382. protected _updateDebugMeshes(): void;
  40383. /**
  40384. * Renders a specified physic impostor
  40385. * @param impostor defines the impostor to render
  40386. * @param targetMesh defines the mesh represented by the impostor
  40387. * @returns the new debug mesh used to render the impostor
  40388. */
  40389. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40390. /**
  40391. * Hides a specified physic impostor
  40392. * @param impostor defines the impostor to hide
  40393. */
  40394. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40395. private _getDebugMaterial;
  40396. private _getDebugBoxMesh;
  40397. private _getDebugSphereMesh;
  40398. private _getDebugCylinderMesh;
  40399. private _getDebugMeshMesh;
  40400. private _getDebugMesh;
  40401. /** Releases all resources */
  40402. dispose(): void;
  40403. }
  40404. }
  40405. declare module BABYLON {
  40406. /**
  40407. * Class containing static functions to help procedurally build meshes
  40408. */
  40409. export class LinesBuilder {
  40410. /**
  40411. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40412. * * 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
  40413. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40414. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40415. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40416. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40417. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40418. * * 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
  40419. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40422. * @param name defines the name of the new line system
  40423. * @param options defines the options used to create the line system
  40424. * @param scene defines the hosting scene
  40425. * @returns a new line system mesh
  40426. */
  40427. static CreateLineSystem(name: string, options: {
  40428. lines: Vector3[][];
  40429. updatable?: boolean;
  40430. instance?: Nullable<LinesMesh>;
  40431. colors?: Nullable<Color4[][]>;
  40432. useVertexAlpha?: boolean;
  40433. }, scene: Nullable<Scene>): LinesMesh;
  40434. /**
  40435. * Creates a line mesh
  40436. * 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
  40437. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40438. * * The parameter `points` is an array successive Vector3
  40439. * * 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
  40440. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40441. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40442. * * When updating an instance, remember that only point positions can change, not the number of points
  40443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40445. * @param name defines the name of the new line system
  40446. * @param options defines the options used to create the line system
  40447. * @param scene defines the hosting scene
  40448. * @returns a new line mesh
  40449. */
  40450. static CreateLines(name: string, options: {
  40451. points: Vector3[];
  40452. updatable?: boolean;
  40453. instance?: Nullable<LinesMesh>;
  40454. colors?: Color4[];
  40455. useVertexAlpha?: boolean;
  40456. }, scene?: Nullable<Scene>): LinesMesh;
  40457. /**
  40458. * Creates a dashed line mesh
  40459. * * 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
  40460. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40461. * * The parameter `points` is an array successive Vector3
  40462. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40463. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40464. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40465. * * 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
  40466. * * When updating an instance, remember that only point positions can change, not the number of points
  40467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40468. * @param name defines the name of the mesh
  40469. * @param options defines the options used to create the mesh
  40470. * @param scene defines the hosting scene
  40471. * @returns the dashed line mesh
  40472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40473. */
  40474. static CreateDashedLines(name: string, options: {
  40475. points: Vector3[];
  40476. dashSize?: number;
  40477. gapSize?: number;
  40478. dashNb?: number;
  40479. updatable?: boolean;
  40480. instance?: LinesMesh;
  40481. }, scene?: Nullable<Scene>): LinesMesh;
  40482. }
  40483. }
  40484. declare module BABYLON {
  40485. /**
  40486. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40487. * in order to better appreciate the issue one might have.
  40488. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40489. */
  40490. export class RayHelper {
  40491. /**
  40492. * Defines the ray we are currently tryin to visualize.
  40493. */
  40494. ray: Nullable<Ray>;
  40495. private _renderPoints;
  40496. private _renderLine;
  40497. private _renderFunction;
  40498. private _scene;
  40499. private _updateToMeshFunction;
  40500. private _attachedToMesh;
  40501. private _meshSpaceDirection;
  40502. private _meshSpaceOrigin;
  40503. /**
  40504. * Helper function to create a colored helper in a scene in one line.
  40505. * @param ray Defines the ray we are currently tryin to visualize
  40506. * @param scene Defines the scene the ray is used in
  40507. * @param color Defines the color we want to see the ray in
  40508. * @returns The newly created ray helper.
  40509. */
  40510. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40511. /**
  40512. * Instantiate a new ray helper.
  40513. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40514. * in order to better appreciate the issue one might have.
  40515. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40516. * @param ray Defines the ray we are currently tryin to visualize
  40517. */
  40518. constructor(ray: Ray);
  40519. /**
  40520. * Shows the ray we are willing to debug.
  40521. * @param scene Defines the scene the ray needs to be rendered in
  40522. * @param color Defines the color the ray needs to be rendered in
  40523. */
  40524. show(scene: Scene, color?: Color3): void;
  40525. /**
  40526. * Hides the ray we are debugging.
  40527. */
  40528. hide(): void;
  40529. private _render;
  40530. /**
  40531. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40532. * @param mesh Defines the mesh we want the helper attached to
  40533. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40534. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40535. * @param length Defines the length of the ray
  40536. */
  40537. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40538. /**
  40539. * Detach the ray helper from the mesh it has previously been attached to.
  40540. */
  40541. detachFromMesh(): void;
  40542. private _updateToMesh;
  40543. /**
  40544. * Dispose the helper and release its associated resources.
  40545. */
  40546. dispose(): void;
  40547. }
  40548. }
  40549. declare module BABYLON.Debug {
  40550. /**
  40551. * Class used to render a debug view of a given skeleton
  40552. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40553. */
  40554. export class SkeletonViewer {
  40555. /** defines the skeleton to render */
  40556. skeleton: Skeleton;
  40557. /** defines the mesh attached to the skeleton */
  40558. mesh: AbstractMesh;
  40559. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40560. autoUpdateBonesMatrices: boolean;
  40561. /** defines the rendering group id to use with the viewer */
  40562. renderingGroupId: number;
  40563. /** Gets or sets the color used to render the skeleton */
  40564. color: Color3;
  40565. private _scene;
  40566. private _debugLines;
  40567. private _debugMesh;
  40568. private _isEnabled;
  40569. private _renderFunction;
  40570. private _utilityLayer;
  40571. /**
  40572. * Returns the mesh used to render the bones
  40573. */
  40574. readonly debugMesh: Nullable<LinesMesh>;
  40575. /**
  40576. * Creates a new SkeletonViewer
  40577. * @param skeleton defines the skeleton to render
  40578. * @param mesh defines the mesh attached to the skeleton
  40579. * @param scene defines the hosting scene
  40580. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40581. * @param renderingGroupId defines the rendering group id to use with the viewer
  40582. */
  40583. constructor(
  40584. /** defines the skeleton to render */
  40585. skeleton: Skeleton,
  40586. /** defines the mesh attached to the skeleton */
  40587. mesh: AbstractMesh, scene: Scene,
  40588. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40589. autoUpdateBonesMatrices?: boolean,
  40590. /** defines the rendering group id to use with the viewer */
  40591. renderingGroupId?: number);
  40592. /** Gets or sets a boolean indicating if the viewer is enabled */
  40593. isEnabled: boolean;
  40594. private _getBonePosition;
  40595. private _getLinesForBonesWithLength;
  40596. private _getLinesForBonesNoLength;
  40597. /** Update the viewer to sync with current skeleton state */
  40598. update(): void;
  40599. /** Release associated resources */
  40600. dispose(): void;
  40601. }
  40602. }
  40603. declare module BABYLON {
  40604. /**
  40605. * Options to create the null engine
  40606. */
  40607. export class NullEngineOptions {
  40608. /**
  40609. * Render width (Default: 512)
  40610. */
  40611. renderWidth: number;
  40612. /**
  40613. * Render height (Default: 256)
  40614. */
  40615. renderHeight: number;
  40616. /**
  40617. * Texture size (Default: 512)
  40618. */
  40619. textureSize: number;
  40620. /**
  40621. * If delta time between frames should be constant
  40622. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40623. */
  40624. deterministicLockstep: boolean;
  40625. /**
  40626. * Maximum about of steps between frames (Default: 4)
  40627. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40628. */
  40629. lockstepMaxSteps: number;
  40630. }
  40631. /**
  40632. * The null engine class provides support for headless version of babylon.js.
  40633. * This can be used in server side scenario or for testing purposes
  40634. */
  40635. export class NullEngine extends Engine {
  40636. private _options;
  40637. /**
  40638. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40639. */
  40640. isDeterministicLockStep(): boolean;
  40641. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40642. getLockstepMaxSteps(): number;
  40643. /**
  40644. * Sets hardware scaling, used to save performance if needed
  40645. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40646. */
  40647. getHardwareScalingLevel(): number;
  40648. constructor(options?: NullEngineOptions);
  40649. createVertexBuffer(vertices: FloatArray): DataBuffer;
  40650. createIndexBuffer(indices: IndicesArray): DataBuffer;
  40651. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40652. getRenderWidth(useScreen?: boolean): number;
  40653. getRenderHeight(useScreen?: boolean): number;
  40654. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40655. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40656. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40657. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40658. bindSamplers(effect: Effect): void;
  40659. enableEffect(effect: Effect): void;
  40660. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40661. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40662. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40663. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40664. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40665. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40666. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40667. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40668. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40669. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40670. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40671. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40672. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40673. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40674. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40675. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40676. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40677. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40678. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40679. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40680. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40681. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40682. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40683. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40684. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40685. bindBuffers(vertexBuffers: {
  40686. [key: string]: VertexBuffer;
  40687. }, indexBuffer: DataBuffer, effect: Effect): void;
  40688. wipeCaches(bruteForce?: boolean): void;
  40689. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40690. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40691. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40692. /** @hidden */ createTexture(): WebGLTexture;
  40693. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  40694. 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;
  40695. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40696. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40697. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40698. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40699. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  40700. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40701. areAllEffectsReady(): boolean;
  40702. /**
  40703. * @hidden
  40704. * Get the current error code of the webGL context
  40705. * @returns the error code
  40706. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40707. */
  40708. getError(): number;
  40709. /** @hidden */ getUnpackAlignement(): number;
  40710. /** @hidden */ unpackFlipY(value: boolean): void;
  40711. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40712. /**
  40713. * Updates a dynamic vertex buffer.
  40714. * @param vertexBuffer the vertex buffer to update
  40715. * @param data the data used to update the vertex buffer
  40716. * @param byteOffset the byte offset of the data (optional)
  40717. * @param byteLength the byte length of the data (optional)
  40718. */
  40719. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40720. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  40721. /** @hidden */ releaseBuffer(buffer: DataBuffer): boolean;
  40722. releaseEffects(): void;
  40723. displayLoadingUI(): void;
  40724. hideLoadingUI(): void;
  40725. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40726. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40727. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40728. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40729. }
  40730. }
  40731. declare module BABYLON {
  40732. /** @hidden */
  40733. export class _OcclusionDataStorage {
  40734. /** @hidden */
  40735. occlusionInternalRetryCounter: number;
  40736. /** @hidden */
  40737. isOcclusionQueryInProgress: boolean;
  40738. /** @hidden */
  40739. isOccluded: boolean;
  40740. /** @hidden */
  40741. occlusionRetryCount: number;
  40742. /** @hidden */
  40743. occlusionType: number;
  40744. /** @hidden */
  40745. occlusionQueryAlgorithmType: number;
  40746. }
  40747. interface Engine {
  40748. /**
  40749. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40750. * @return the new query
  40751. */
  40752. createQuery(): WebGLQuery;
  40753. /**
  40754. * Delete and release a webGL query
  40755. * @param query defines the query to delete
  40756. * @return the current engine
  40757. */
  40758. deleteQuery(query: WebGLQuery): Engine;
  40759. /**
  40760. * Check if a given query has resolved and got its value
  40761. * @param query defines the query to check
  40762. * @returns true if the query got its value
  40763. */
  40764. isQueryResultAvailable(query: WebGLQuery): boolean;
  40765. /**
  40766. * Gets the value of a given query
  40767. * @param query defines the query to check
  40768. * @returns the value of the query
  40769. */
  40770. getQueryResult(query: WebGLQuery): number;
  40771. /**
  40772. * Initiates an occlusion query
  40773. * @param algorithmType defines the algorithm to use
  40774. * @param query defines the query to use
  40775. * @returns the current engine
  40776. * @see http://doc.babylonjs.com/features/occlusionquery
  40777. */
  40778. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40779. /**
  40780. * Ends an occlusion query
  40781. * @see http://doc.babylonjs.com/features/occlusionquery
  40782. * @param algorithmType defines the algorithm to use
  40783. * @returns the current engine
  40784. */
  40785. endOcclusionQuery(algorithmType: number): Engine;
  40786. /**
  40787. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40788. * Please note that only one query can be issued at a time
  40789. * @returns a time token used to track the time span
  40790. */
  40791. startTimeQuery(): Nullable<_TimeToken>;
  40792. /**
  40793. * Ends a time query
  40794. * @param token defines the token used to measure the time span
  40795. * @returns the time spent (in ns)
  40796. */
  40797. endTimeQuery(token: _TimeToken): int;
  40798. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  40799. /** @hidden */ createTimeQuery(): WebGLQuery;
  40800. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  40801. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  40802. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  40803. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  40804. }
  40805. interface AbstractMesh {
  40806. /**
  40807. * Backing filed
  40808. * @hidden
  40809. */ private _occlusionDataStorage: _OcclusionDataStorage;
  40810. /**
  40811. * Access property
  40812. * @hidden
  40813. */ occlusionDataStorage: _OcclusionDataStorage;
  40814. /**
  40815. * 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.
  40816. * The default value is -1 which means don't break the query and wait till the result
  40817. * @see http://doc.babylonjs.com/features/occlusionquery
  40818. */
  40819. occlusionRetryCount: number;
  40820. /**
  40821. * 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:
  40822. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40823. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40824. * * 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.
  40825. * @see http://doc.babylonjs.com/features/occlusionquery
  40826. */
  40827. occlusionType: number;
  40828. /**
  40829. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40830. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40831. * * 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.
  40832. * @see http://doc.babylonjs.com/features/occlusionquery
  40833. */
  40834. occlusionQueryAlgorithmType: number;
  40835. /**
  40836. * 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
  40837. * @see http://doc.babylonjs.com/features/occlusionquery
  40838. */
  40839. isOccluded: boolean;
  40840. /**
  40841. * Flag to check the progress status of the query
  40842. * @see http://doc.babylonjs.com/features/occlusionquery
  40843. */
  40844. isOcclusionQueryInProgress: boolean;
  40845. }
  40846. }
  40847. declare module BABYLON {
  40848. /** @hidden */
  40849. export var _forceTransformFeedbackToBundle: boolean;
  40850. interface Engine {
  40851. /**
  40852. * Creates a webGL transform feedback object
  40853. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40854. * @returns the webGL transform feedback object
  40855. */
  40856. createTransformFeedback(): WebGLTransformFeedback;
  40857. /**
  40858. * Delete a webGL transform feedback object
  40859. * @param value defines the webGL transform feedback object to delete
  40860. */
  40861. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40862. /**
  40863. * Bind a webGL transform feedback object to the webgl context
  40864. * @param value defines the webGL transform feedback object to bind
  40865. */
  40866. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40867. /**
  40868. * Begins a transform feedback operation
  40869. * @param usePoints defines if points or triangles must be used
  40870. */
  40871. beginTransformFeedback(usePoints: boolean): void;
  40872. /**
  40873. * Ends a transform feedback operation
  40874. */
  40875. endTransformFeedback(): void;
  40876. /**
  40877. * Specify the varyings to use with transform feedback
  40878. * @param program defines the associated webGL program
  40879. * @param value defines the list of strings representing the varying names
  40880. */
  40881. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40882. /**
  40883. * Bind a webGL buffer for a transform feedback operation
  40884. * @param value defines the webGL buffer to bind
  40885. */
  40886. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40887. }
  40888. }
  40889. declare module BABYLON {
  40890. /**
  40891. * Creation options of the multi render target texture.
  40892. */
  40893. export interface IMultiRenderTargetOptions {
  40894. /**
  40895. * Define if the texture needs to create mip maps after render.
  40896. */
  40897. generateMipMaps?: boolean;
  40898. /**
  40899. * Define the types of all the draw buffers we want to create
  40900. */
  40901. types?: number[];
  40902. /**
  40903. * Define the sampling modes of all the draw buffers we want to create
  40904. */
  40905. samplingModes?: number[];
  40906. /**
  40907. * Define if a depth buffer is required
  40908. */
  40909. generateDepthBuffer?: boolean;
  40910. /**
  40911. * Define if a stencil buffer is required
  40912. */
  40913. generateStencilBuffer?: boolean;
  40914. /**
  40915. * Define if a depth texture is required instead of a depth buffer
  40916. */
  40917. generateDepthTexture?: boolean;
  40918. /**
  40919. * Define the number of desired draw buffers
  40920. */
  40921. textureCount?: number;
  40922. /**
  40923. * Define if aspect ratio should be adapted to the texture or stay the scene one
  40924. */
  40925. doNotChangeAspectRatio?: boolean;
  40926. /**
  40927. * Define the default type of the buffers we are creating
  40928. */
  40929. defaultType?: number;
  40930. }
  40931. /**
  40932. * A multi render target, like a render target provides the ability to render to a texture.
  40933. * Unlike the render target, it can render to several draw buffers in one draw.
  40934. * This is specially interesting in deferred rendering or for any effects requiring more than
  40935. * just one color from a single pass.
  40936. */
  40937. export class MultiRenderTarget extends RenderTargetTexture {
  40938. private _internalTextures;
  40939. private _textures;
  40940. private _multiRenderTargetOptions;
  40941. /**
  40942. * Get if draw buffers are currently supported by the used hardware and browser.
  40943. */
  40944. readonly isSupported: boolean;
  40945. /**
  40946. * Get the list of textures generated by the multi render target.
  40947. */
  40948. readonly textures: Texture[];
  40949. /**
  40950. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  40951. */
  40952. readonly depthTexture: Texture;
  40953. /**
  40954. * Set the wrapping mode on U of all the textures we are rendering to.
  40955. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40956. */
  40957. wrapU: number;
  40958. /**
  40959. * Set the wrapping mode on V of all the textures we are rendering to.
  40960. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40961. */
  40962. wrapV: number;
  40963. /**
  40964. * Instantiate a new multi render target texture.
  40965. * A multi render target, like a render target provides the ability to render to a texture.
  40966. * Unlike the render target, it can render to several draw buffers in one draw.
  40967. * This is specially interesting in deferred rendering or for any effects requiring more than
  40968. * just one color from a single pass.
  40969. * @param name Define the name of the texture
  40970. * @param size Define the size of the buffers to render to
  40971. * @param count Define the number of target we are rendering into
  40972. * @param scene Define the scene the texture belongs to
  40973. * @param options Define the options used to create the multi render target
  40974. */
  40975. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  40976. /** @hidden */ rebuild(): void;
  40977. private _createInternalTextures;
  40978. private _createTextures;
  40979. /**
  40980. * Define the number of samples used if MSAA is enabled.
  40981. */
  40982. samples: number;
  40983. /**
  40984. * Resize all the textures in the multi render target.
  40985. * Be carrefull as it will recreate all the data in the new texture.
  40986. * @param size Define the new size
  40987. */
  40988. resize(size: any): void;
  40989. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  40990. /**
  40991. * Dispose the render targets and their associated resources
  40992. */
  40993. dispose(): void;
  40994. /**
  40995. * Release all the underlying texture used as draw buffers.
  40996. */
  40997. releaseInternalTextures(): void;
  40998. }
  40999. }
  41000. declare module BABYLON {
  41001. interface Engine {
  41002. /**
  41003. * Unbind a list of render target textures from the webGL context
  41004. * This is used only when drawBuffer extension or webGL2 are active
  41005. * @param textures defines the render target textures to unbind
  41006. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41007. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41008. */
  41009. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41010. /**
  41011. * Create a multi render target texture
  41012. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41013. * @param size defines the size of the texture
  41014. * @param options defines the creation options
  41015. * @returns the cube texture as an InternalTexture
  41016. */
  41017. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41018. /**
  41019. * Update the sample count for a given multiple render target texture
  41020. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41021. * @param textures defines the textures to update
  41022. * @param samples defines the sample count to set
  41023. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41024. */
  41025. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41026. }
  41027. }
  41028. declare module BABYLON {
  41029. /**
  41030. * Gather the list of clipboard event types as constants.
  41031. */
  41032. export class ClipboardEventTypes {
  41033. /**
  41034. * The clipboard event is fired when a copy command is active (pressed).
  41035. */
  41036. static readonly COPY: number;
  41037. /**
  41038. * The clipboard event is fired when a cut command is active (pressed).
  41039. */
  41040. static readonly CUT: number;
  41041. /**
  41042. * The clipboard event is fired when a paste command is active (pressed).
  41043. */
  41044. static readonly PASTE: number;
  41045. }
  41046. /**
  41047. * This class is used to store clipboard related info for the onClipboardObservable event.
  41048. */
  41049. export class ClipboardInfo {
  41050. /**
  41051. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41052. */
  41053. type: number;
  41054. /**
  41055. * Defines the related dom event
  41056. */
  41057. event: ClipboardEvent;
  41058. /**
  41059. *Creates an instance of ClipboardInfo.
  41060. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41061. * @param event Defines the related dom event
  41062. */
  41063. constructor(
  41064. /**
  41065. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41066. */
  41067. type: number,
  41068. /**
  41069. * Defines the related dom event
  41070. */
  41071. event: ClipboardEvent);
  41072. /**
  41073. * Get the clipboard event's type from the keycode.
  41074. * @param keyCode Defines the keyCode for the current keyboard event.
  41075. * @return {number}
  41076. */
  41077. static GetTypeFromCharacter(keyCode: number): number;
  41078. }
  41079. }
  41080. declare module BABYLON {
  41081. /**
  41082. * Class used to represent data loading progression
  41083. */
  41084. export class SceneLoaderProgressEvent {
  41085. /** defines if data length to load can be evaluated */
  41086. readonly lengthComputable: boolean;
  41087. /** defines the loaded data length */
  41088. readonly loaded: number;
  41089. /** defines the data length to load */
  41090. readonly total: number;
  41091. /**
  41092. * Create a new progress event
  41093. * @param lengthComputable defines if data length to load can be evaluated
  41094. * @param loaded defines the loaded data length
  41095. * @param total defines the data length to load
  41096. */
  41097. constructor(
  41098. /** defines if data length to load can be evaluated */
  41099. lengthComputable: boolean,
  41100. /** defines the loaded data length */
  41101. loaded: number,
  41102. /** defines the data length to load */
  41103. total: number);
  41104. /**
  41105. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41106. * @param event defines the source event
  41107. * @returns a new SceneLoaderProgressEvent
  41108. */
  41109. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41110. }
  41111. /**
  41112. * Interface used by SceneLoader plugins to define supported file extensions
  41113. */
  41114. export interface ISceneLoaderPluginExtensions {
  41115. /**
  41116. * Defines the list of supported extensions
  41117. */
  41118. [extension: string]: {
  41119. isBinary: boolean;
  41120. };
  41121. }
  41122. /**
  41123. * Interface used by SceneLoader plugin factory
  41124. */
  41125. export interface ISceneLoaderPluginFactory {
  41126. /**
  41127. * Defines the name of the factory
  41128. */
  41129. name: string;
  41130. /**
  41131. * Function called to create a new plugin
  41132. * @return the new plugin
  41133. */
  41134. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41135. /**
  41136. * Boolean indicating if the plugin can direct load specific data
  41137. */
  41138. canDirectLoad?: (data: string) => boolean;
  41139. }
  41140. /**
  41141. * Interface used to define a SceneLoader plugin
  41142. */
  41143. export interface ISceneLoaderPlugin {
  41144. /**
  41145. * The friendly name of this plugin.
  41146. */
  41147. name: string;
  41148. /**
  41149. * The file extensions supported by this plugin.
  41150. */
  41151. extensions: string | ISceneLoaderPluginExtensions;
  41152. /**
  41153. * Import meshes into a scene.
  41154. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41155. * @param scene The scene to import into
  41156. * @param data The data to import
  41157. * @param rootUrl The root url for scene and resources
  41158. * @param meshes The meshes array to import into
  41159. * @param particleSystems The particle systems array to import into
  41160. * @param skeletons The skeletons array to import into
  41161. * @param onError The callback when import fails
  41162. * @returns True if successful or false otherwise
  41163. */
  41164. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41165. /**
  41166. * Load into a scene.
  41167. * @param scene The scene to load into
  41168. * @param data The data to import
  41169. * @param rootUrl The root url for scene and resources
  41170. * @param onError The callback when import fails
  41171. * @returns true if successful or false otherwise
  41172. */
  41173. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41174. /**
  41175. * The callback that returns true if the data can be directly loaded.
  41176. */
  41177. canDirectLoad?: (data: string) => boolean;
  41178. /**
  41179. * The callback that allows custom handling of the root url based on the response url.
  41180. */
  41181. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41182. /**
  41183. * Load into an asset container.
  41184. * @param scene The scene to load into
  41185. * @param data The data to import
  41186. * @param rootUrl The root url for scene and resources
  41187. * @param onError The callback when import fails
  41188. * @returns The loaded asset container
  41189. */
  41190. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41191. }
  41192. /**
  41193. * Interface used to define an async SceneLoader plugin
  41194. */
  41195. export interface ISceneLoaderPluginAsync {
  41196. /**
  41197. * The friendly name of this plugin.
  41198. */
  41199. name: string;
  41200. /**
  41201. * The file extensions supported by this plugin.
  41202. */
  41203. extensions: string | ISceneLoaderPluginExtensions;
  41204. /**
  41205. * Import meshes into a scene.
  41206. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41207. * @param scene The scene to import into
  41208. * @param data The data to import
  41209. * @param rootUrl The root url for scene and resources
  41210. * @param onProgress The callback when the load progresses
  41211. * @param fileName Defines the name of the file to load
  41212. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41213. */
  41214. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41215. meshes: AbstractMesh[];
  41216. particleSystems: IParticleSystem[];
  41217. skeletons: Skeleton[];
  41218. animationGroups: AnimationGroup[];
  41219. }>;
  41220. /**
  41221. * Load into a scene.
  41222. * @param scene The scene to load into
  41223. * @param data The data to import
  41224. * @param rootUrl The root url for scene and resources
  41225. * @param onProgress The callback when the load progresses
  41226. * @param fileName Defines the name of the file to load
  41227. * @returns Nothing
  41228. */
  41229. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41230. /**
  41231. * The callback that returns true if the data can be directly loaded.
  41232. */
  41233. canDirectLoad?: (data: string) => boolean;
  41234. /**
  41235. * The callback that allows custom handling of the root url based on the response url.
  41236. */
  41237. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41238. /**
  41239. * Load into an asset container.
  41240. * @param scene The scene to load into
  41241. * @param data The data to import
  41242. * @param rootUrl The root url for scene and resources
  41243. * @param onProgress The callback when the load progresses
  41244. * @param fileName Defines the name of the file to load
  41245. * @returns The loaded asset container
  41246. */
  41247. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41248. }
  41249. /**
  41250. * Class used to load scene from various file formats using registered plugins
  41251. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41252. */
  41253. export class SceneLoader {
  41254. /**
  41255. * No logging while loading
  41256. */
  41257. static readonly NO_LOGGING: number;
  41258. /**
  41259. * Minimal logging while loading
  41260. */
  41261. static readonly MINIMAL_LOGGING: number;
  41262. /**
  41263. * Summary logging while loading
  41264. */
  41265. static readonly SUMMARY_LOGGING: number;
  41266. /**
  41267. * Detailled logging while loading
  41268. */
  41269. static readonly DETAILED_LOGGING: number;
  41270. /**
  41271. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41272. */
  41273. static ForceFullSceneLoadingForIncremental: boolean;
  41274. /**
  41275. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41276. */
  41277. static ShowLoadingScreen: boolean;
  41278. /**
  41279. * Defines the current logging level (while loading the scene)
  41280. * @ignorenaming
  41281. */
  41282. static loggingLevel: number;
  41283. /**
  41284. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41285. */
  41286. static CleanBoneMatrixWeights: boolean;
  41287. /**
  41288. * Event raised when a plugin is used to load a scene
  41289. */
  41290. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41291. private static _registeredPlugins;
  41292. private static _getDefaultPlugin;
  41293. private static _getPluginForExtension;
  41294. private static _getPluginForDirectLoad;
  41295. private static _getPluginForFilename;
  41296. private static _getDirectLoad;
  41297. private static _loadData;
  41298. private static _getFileInfo;
  41299. /**
  41300. * Gets a plugin that can load the given extension
  41301. * @param extension defines the extension to load
  41302. * @returns a plugin or null if none works
  41303. */
  41304. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41305. /**
  41306. * Gets a boolean indicating that the given extension can be loaded
  41307. * @param extension defines the extension to load
  41308. * @returns true if the extension is supported
  41309. */
  41310. static IsPluginForExtensionAvailable(extension: string): boolean;
  41311. /**
  41312. * Adds a new plugin to the list of registered plugins
  41313. * @param plugin defines the plugin to add
  41314. */
  41315. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41316. /**
  41317. * Import meshes into a scene
  41318. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41319. * @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)
  41320. * @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)
  41321. * @param scene the instance of BABYLON.Scene to append to
  41322. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41323. * @param onProgress a callback with a progress event for each file being loaded
  41324. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41325. * @param pluginExtension the extension used to determine the plugin
  41326. * @returns The loaded plugin
  41327. */
  41328. 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>;
  41329. /**
  41330. * Import meshes into a scene
  41331. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41332. * @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)
  41333. * @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)
  41334. * @param scene the instance of BABYLON.Scene to append to
  41335. * @param onProgress a callback with a progress event for each file being loaded
  41336. * @param pluginExtension the extension used to determine the plugin
  41337. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41338. */
  41339. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41340. meshes: AbstractMesh[];
  41341. particleSystems: IParticleSystem[];
  41342. skeletons: Skeleton[];
  41343. animationGroups: AnimationGroup[];
  41344. }>;
  41345. /**
  41346. * Load a scene
  41347. * @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)
  41348. * @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)
  41349. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41350. * @param onSuccess a callback with the scene when import succeeds
  41351. * @param onProgress a callback with a progress event for each file being loaded
  41352. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41353. * @param pluginExtension the extension used to determine the plugin
  41354. * @returns The loaded plugin
  41355. */
  41356. 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>;
  41357. /**
  41358. * Load a scene
  41359. * @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)
  41360. * @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)
  41361. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41362. * @param onProgress a callback with a progress event for each file being loaded
  41363. * @param pluginExtension the extension used to determine the plugin
  41364. * @returns The loaded scene
  41365. */
  41366. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41367. /**
  41368. * Append a scene
  41369. * @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)
  41370. * @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)
  41371. * @param scene is the instance of BABYLON.Scene to append to
  41372. * @param onSuccess a callback with the scene when import succeeds
  41373. * @param onProgress a callback with a progress event for each file being loaded
  41374. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41375. * @param pluginExtension the extension used to determine the plugin
  41376. * @returns The loaded plugin
  41377. */
  41378. 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>;
  41379. /**
  41380. * Append a scene
  41381. * @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)
  41382. * @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)
  41383. * @param scene is the instance of BABYLON.Scene to append to
  41384. * @param onProgress a callback with a progress event for each file being loaded
  41385. * @param pluginExtension the extension used to determine the plugin
  41386. * @returns The given scene
  41387. */
  41388. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41389. /**
  41390. * Load a scene into an asset container
  41391. * @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)
  41392. * @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)
  41393. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41394. * @param onSuccess a callback with the scene when import succeeds
  41395. * @param onProgress a callback with a progress event for each file being loaded
  41396. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41397. * @param pluginExtension the extension used to determine the plugin
  41398. * @returns The loaded plugin
  41399. */
  41400. 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>;
  41401. /**
  41402. * Load a scene into an asset container
  41403. * @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)
  41404. * @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)
  41405. * @param scene is the instance of Scene to append to
  41406. * @param onProgress a callback with a progress event for each file being loaded
  41407. * @param pluginExtension the extension used to determine the plugin
  41408. * @returns The loaded asset container
  41409. */
  41410. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41411. }
  41412. }
  41413. declare module BABYLON {
  41414. /**
  41415. * Google Daydream controller
  41416. */
  41417. export class DaydreamController extends WebVRController {
  41418. /**
  41419. * Base Url for the controller model.
  41420. */
  41421. static MODEL_BASE_URL: string;
  41422. /**
  41423. * File name for the controller model.
  41424. */
  41425. static MODEL_FILENAME: string;
  41426. /**
  41427. * Gamepad Id prefix used to identify Daydream Controller.
  41428. */
  41429. static readonly GAMEPAD_ID_PREFIX: string;
  41430. /**
  41431. * Creates a new DaydreamController from a gamepad
  41432. * @param vrGamepad the gamepad that the controller should be created from
  41433. */
  41434. constructor(vrGamepad: any);
  41435. /**
  41436. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41437. * @param scene scene in which to add meshes
  41438. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41439. */
  41440. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41441. /**
  41442. * Called once for each button that changed state since the last frame
  41443. * @param buttonIdx Which button index changed
  41444. * @param state New state of the button
  41445. * @param changes Which properties on the state changed since last frame
  41446. */
  41447. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41448. }
  41449. }
  41450. declare module BABYLON {
  41451. /**
  41452. * Gear VR Controller
  41453. */
  41454. export class GearVRController extends WebVRController {
  41455. /**
  41456. * Base Url for the controller model.
  41457. */
  41458. static MODEL_BASE_URL: string;
  41459. /**
  41460. * File name for the controller model.
  41461. */
  41462. static MODEL_FILENAME: string;
  41463. /**
  41464. * Gamepad Id prefix used to identify this controller.
  41465. */
  41466. static readonly GAMEPAD_ID_PREFIX: string;
  41467. private readonly _buttonIndexToObservableNameMap;
  41468. /**
  41469. * Creates a new GearVRController from a gamepad
  41470. * @param vrGamepad the gamepad that the controller should be created from
  41471. */
  41472. constructor(vrGamepad: any);
  41473. /**
  41474. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41475. * @param scene scene in which to add meshes
  41476. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41477. */
  41478. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41479. /**
  41480. * Called once for each button that changed state since the last frame
  41481. * @param buttonIdx Which button index changed
  41482. * @param state New state of the button
  41483. * @param changes Which properties on the state changed since last frame
  41484. */
  41485. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41486. }
  41487. }
  41488. declare module BABYLON {
  41489. /**
  41490. * Generic Controller
  41491. */
  41492. export class GenericController extends WebVRController {
  41493. /**
  41494. * Base Url for the controller model.
  41495. */
  41496. static readonly MODEL_BASE_URL: string;
  41497. /**
  41498. * File name for the controller model.
  41499. */
  41500. static readonly MODEL_FILENAME: string;
  41501. /**
  41502. * Creates a new GenericController from a gamepad
  41503. * @param vrGamepad the gamepad that the controller should be created from
  41504. */
  41505. constructor(vrGamepad: any);
  41506. /**
  41507. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41508. * @param scene scene in which to add meshes
  41509. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41510. */
  41511. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41512. /**
  41513. * Called once for each button that changed state since the last frame
  41514. * @param buttonIdx Which button index changed
  41515. * @param state New state of the button
  41516. * @param changes Which properties on the state changed since last frame
  41517. */
  41518. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41519. }
  41520. }
  41521. declare module BABYLON {
  41522. /**
  41523. * Oculus Touch Controller
  41524. */
  41525. export class OculusTouchController extends WebVRController {
  41526. /**
  41527. * Base Url for the controller model.
  41528. */
  41529. static MODEL_BASE_URL: string;
  41530. /**
  41531. * File name for the left controller model.
  41532. */
  41533. static MODEL_LEFT_FILENAME: string;
  41534. /**
  41535. * File name for the right controller model.
  41536. */
  41537. static MODEL_RIGHT_FILENAME: string;
  41538. /**
  41539. * Fired when the secondary trigger on this controller is modified
  41540. */
  41541. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41542. /**
  41543. * Fired when the thumb rest on this controller is modified
  41544. */
  41545. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41546. /**
  41547. * Creates a new OculusTouchController from a gamepad
  41548. * @param vrGamepad the gamepad that the controller should be created from
  41549. */
  41550. constructor(vrGamepad: any);
  41551. /**
  41552. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41553. * @param scene scene in which to add meshes
  41554. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41555. */
  41556. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41557. /**
  41558. * Fired when the A button on this controller is modified
  41559. */
  41560. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41561. /**
  41562. * Fired when the B button on this controller is modified
  41563. */
  41564. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41565. /**
  41566. * Fired when the X button on this controller is modified
  41567. */
  41568. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41569. /**
  41570. * Fired when the Y button on this controller is modified
  41571. */
  41572. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41573. /**
  41574. * Called once for each button that changed state since the last frame
  41575. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41576. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41577. * 2) secondary trigger (same)
  41578. * 3) A (right) X (left), touch, pressed = value
  41579. * 4) B / Y
  41580. * 5) thumb rest
  41581. * @param buttonIdx Which button index changed
  41582. * @param state New state of the button
  41583. * @param changes Which properties on the state changed since last frame
  41584. */
  41585. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41586. }
  41587. }
  41588. declare module BABYLON {
  41589. /**
  41590. * Vive Controller
  41591. */
  41592. export class ViveController extends WebVRController {
  41593. /**
  41594. * Base Url for the controller model.
  41595. */
  41596. static MODEL_BASE_URL: string;
  41597. /**
  41598. * File name for the controller model.
  41599. */
  41600. static MODEL_FILENAME: string;
  41601. /**
  41602. * Creates a new ViveController from a gamepad
  41603. * @param vrGamepad the gamepad that the controller should be created from
  41604. */
  41605. constructor(vrGamepad: any);
  41606. /**
  41607. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41608. * @param scene scene in which to add meshes
  41609. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41610. */
  41611. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41612. /**
  41613. * Fired when the left button on this controller is modified
  41614. */
  41615. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41616. /**
  41617. * Fired when the right button on this controller is modified
  41618. */
  41619. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41620. /**
  41621. * Fired when the menu button on this controller is modified
  41622. */
  41623. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41624. /**
  41625. * Called once for each button that changed state since the last frame
  41626. * Vive mapping:
  41627. * 0: touchpad
  41628. * 1: trigger
  41629. * 2: left AND right buttons
  41630. * 3: menu button
  41631. * @param buttonIdx Which button index changed
  41632. * @param state New state of the button
  41633. * @param changes Which properties on the state changed since last frame
  41634. */
  41635. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41636. }
  41637. }
  41638. declare module BABYLON {
  41639. /**
  41640. * Defines the WindowsMotionController object that the state of the windows motion controller
  41641. */
  41642. export class WindowsMotionController extends WebVRController {
  41643. /**
  41644. * The base url used to load the left and right controller models
  41645. */
  41646. static MODEL_BASE_URL: string;
  41647. /**
  41648. * The name of the left controller model file
  41649. */
  41650. static MODEL_LEFT_FILENAME: string;
  41651. /**
  41652. * The name of the right controller model file
  41653. */
  41654. static MODEL_RIGHT_FILENAME: string;
  41655. /**
  41656. * The controller name prefix for this controller type
  41657. */
  41658. static readonly GAMEPAD_ID_PREFIX: string;
  41659. /**
  41660. * The controller id pattern for this controller type
  41661. */
  41662. private static readonly GAMEPAD_ID_PATTERN;
  41663. private _loadedMeshInfo;
  41664. private readonly _mapping;
  41665. /**
  41666. * Fired when the trackpad on this controller is clicked
  41667. */
  41668. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41669. /**
  41670. * Fired when the trackpad on this controller is modified
  41671. */
  41672. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41673. /**
  41674. * The current x and y values of this controller's trackpad
  41675. */
  41676. trackpad: StickValues;
  41677. /**
  41678. * Creates a new WindowsMotionController from a gamepad
  41679. * @param vrGamepad the gamepad that the controller should be created from
  41680. */
  41681. constructor(vrGamepad: any);
  41682. /**
  41683. * Fired when the trigger on this controller is modified
  41684. */
  41685. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41686. /**
  41687. * Fired when the menu button on this controller is modified
  41688. */
  41689. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41690. /**
  41691. * Fired when the grip button on this controller is modified
  41692. */
  41693. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41694. /**
  41695. * Fired when the thumbstick button on this controller is modified
  41696. */
  41697. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41698. /**
  41699. * Fired when the touchpad button on this controller is modified
  41700. */
  41701. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41702. /**
  41703. * Fired when the touchpad values on this controller are modified
  41704. */
  41705. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41706. private _updateTrackpad;
  41707. /**
  41708. * Called once per frame by the engine.
  41709. */
  41710. update(): void;
  41711. /**
  41712. * Called once for each button that changed state since the last frame
  41713. * @param buttonIdx Which button index changed
  41714. * @param state New state of the button
  41715. * @param changes Which properties on the state changed since last frame
  41716. */
  41717. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41718. /**
  41719. * Moves the buttons on the controller mesh based on their current state
  41720. * @param buttonName the name of the button to move
  41721. * @param buttonValue the value of the button which determines the buttons new position
  41722. */
  41723. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41724. /**
  41725. * Moves the axis on the controller mesh based on its current state
  41726. * @param axis the index of the axis
  41727. * @param axisValue the value of the axis which determines the meshes new position
  41728. * @hidden
  41729. */
  41730. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41731. /**
  41732. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41733. * @param scene scene in which to add meshes
  41734. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41735. */
  41736. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41737. /**
  41738. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41739. * can be transformed by button presses and axes values, based on this._mapping.
  41740. *
  41741. * @param scene scene in which the meshes exist
  41742. * @param meshes list of meshes that make up the controller model to process
  41743. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41744. */
  41745. private processModel;
  41746. private createMeshInfo;
  41747. /**
  41748. * Gets the ray of the controller in the direction the controller is pointing
  41749. * @param length the length the resulting ray should be
  41750. * @returns a ray in the direction the controller is pointing
  41751. */
  41752. getForwardRay(length?: number): Ray;
  41753. /**
  41754. * Disposes of the controller
  41755. */
  41756. dispose(): void;
  41757. }
  41758. }
  41759. declare module BABYLON {
  41760. /**
  41761. * Single axis scale gizmo
  41762. */
  41763. export class AxisScaleGizmo extends Gizmo {
  41764. private _coloredMaterial;
  41765. /**
  41766. * Drag behavior responsible for the gizmos dragging interactions
  41767. */
  41768. dragBehavior: PointerDragBehavior;
  41769. private _pointerObserver;
  41770. /**
  41771. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41772. */
  41773. snapDistance: number;
  41774. /**
  41775. * Event that fires each time the gizmo snaps to a new location.
  41776. * * snapDistance is the the change in distance
  41777. */
  41778. onSnapObservable: Observable<{
  41779. snapDistance: number;
  41780. }>;
  41781. /**
  41782. * If the scaling operation should be done on all axis (default: false)
  41783. */
  41784. uniformScaling: boolean;
  41785. /**
  41786. * Creates an AxisScaleGizmo
  41787. * @param gizmoLayer The utility layer the gizmo will be added to
  41788. * @param dragAxis The axis which the gizmo will be able to scale on
  41789. * @param color The color of the gizmo
  41790. */
  41791. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41792. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41793. /**
  41794. * Disposes of the gizmo
  41795. */
  41796. dispose(): void;
  41797. /**
  41798. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41799. * @param mesh The mesh to replace the default mesh of the gizmo
  41800. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41801. */
  41802. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41803. }
  41804. }
  41805. declare module BABYLON {
  41806. /**
  41807. * Bounding box gizmo
  41808. */
  41809. export class BoundingBoxGizmo extends Gizmo {
  41810. private _lineBoundingBox;
  41811. private _rotateSpheresParent;
  41812. private _scaleBoxesParent;
  41813. private _boundingDimensions;
  41814. private _renderObserver;
  41815. private _pointerObserver;
  41816. private _scaleDragSpeed;
  41817. private _tmpQuaternion;
  41818. private _tmpVector;
  41819. private _tmpRotationMatrix;
  41820. /**
  41821. * 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)
  41822. */
  41823. ignoreChildren: boolean;
  41824. /**
  41825. * 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)
  41826. */
  41827. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41828. /**
  41829. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41830. */
  41831. rotationSphereSize: number;
  41832. /**
  41833. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41834. */
  41835. scaleBoxSize: number;
  41836. /**
  41837. * 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)
  41838. */
  41839. fixedDragMeshScreenSize: boolean;
  41840. /**
  41841. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41842. */
  41843. fixedDragMeshScreenSizeDistanceFactor: number;
  41844. /**
  41845. * Fired when a rotation sphere or scale box is dragged
  41846. */
  41847. onDragStartObservable: Observable<{}>;
  41848. /**
  41849. * Fired when a scale box is dragged
  41850. */
  41851. onScaleBoxDragObservable: Observable<{}>;
  41852. /**
  41853. * Fired when a scale box drag is ended
  41854. */
  41855. onScaleBoxDragEndObservable: Observable<{}>;
  41856. /**
  41857. * Fired when a rotation sphere is dragged
  41858. */
  41859. onRotationSphereDragObservable: Observable<{}>;
  41860. /**
  41861. * Fired when a rotation sphere drag is ended
  41862. */
  41863. onRotationSphereDragEndObservable: Observable<{}>;
  41864. /**
  41865. * 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)
  41866. */
  41867. scalePivot: Nullable<Vector3>;
  41868. /**
  41869. * Mesh used as a pivot to rotate the attached mesh
  41870. */
  41871. private _anchorMesh;
  41872. private _existingMeshScale;
  41873. private _dragMesh;
  41874. private pointerDragBehavior;
  41875. private coloredMaterial;
  41876. private hoverColoredMaterial;
  41877. /**
  41878. * Sets the color of the bounding box gizmo
  41879. * @param color the color to set
  41880. */
  41881. setColor(color: Color3): void;
  41882. /**
  41883. * Creates an BoundingBoxGizmo
  41884. * @param gizmoLayer The utility layer the gizmo will be added to
  41885. * @param color The color of the gizmo
  41886. */
  41887. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41888. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41889. private _selectNode;
  41890. /**
  41891. * Updates the bounding box information for the Gizmo
  41892. */
  41893. updateBoundingBox(): void;
  41894. private _updateRotationSpheres;
  41895. private _updateScaleBoxes;
  41896. /**
  41897. * Enables rotation on the specified axis and disables rotation on the others
  41898. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41899. */
  41900. setEnabledRotationAxis(axis: string): void;
  41901. /**
  41902. * Enables/disables scaling
  41903. * @param enable if scaling should be enabled
  41904. */
  41905. setEnabledScaling(enable: boolean): void;
  41906. private _updateDummy;
  41907. /**
  41908. * Enables a pointer drag behavior on the bounding box of the gizmo
  41909. */
  41910. enableDragBehavior(): void;
  41911. /**
  41912. * Disposes of the gizmo
  41913. */
  41914. dispose(): void;
  41915. /**
  41916. * 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)
  41917. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41918. * @returns the bounding box mesh with the passed in mesh as a child
  41919. */
  41920. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41921. /**
  41922. * CustomMeshes are not supported by this gizmo
  41923. * @param mesh The mesh to replace the default mesh of the gizmo
  41924. */
  41925. setCustomMesh(mesh: Mesh): void;
  41926. }
  41927. }
  41928. declare module BABYLON {
  41929. /**
  41930. * Single plane rotation gizmo
  41931. */
  41932. export class PlaneRotationGizmo extends Gizmo {
  41933. /**
  41934. * Drag behavior responsible for the gizmos dragging interactions
  41935. */
  41936. dragBehavior: PointerDragBehavior;
  41937. private _pointerObserver;
  41938. /**
  41939. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41940. */
  41941. snapDistance: number;
  41942. /**
  41943. * Event that fires each time the gizmo snaps to a new location.
  41944. * * snapDistance is the the change in distance
  41945. */
  41946. onSnapObservable: Observable<{
  41947. snapDistance: number;
  41948. }>;
  41949. /**
  41950. * Creates a PlaneRotationGizmo
  41951. * @param gizmoLayer The utility layer the gizmo will be added to
  41952. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41953. * @param color The color of the gizmo
  41954. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41955. */
  41956. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41957. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41958. /**
  41959. * Disposes of the gizmo
  41960. */
  41961. dispose(): void;
  41962. }
  41963. }
  41964. declare module BABYLON {
  41965. /**
  41966. * Gizmo that enables rotating a mesh along 3 axis
  41967. */
  41968. export class RotationGizmo extends Gizmo {
  41969. /**
  41970. * Internal gizmo used for interactions on the x axis
  41971. */
  41972. xGizmo: PlaneRotationGizmo;
  41973. /**
  41974. * Internal gizmo used for interactions on the y axis
  41975. */
  41976. yGizmo: PlaneRotationGizmo;
  41977. /**
  41978. * Internal gizmo used for interactions on the z axis
  41979. */
  41980. zGizmo: PlaneRotationGizmo;
  41981. /** Fires an event when any of it's sub gizmos are dragged */
  41982. onDragStartObservable: Observable<{}>;
  41983. /** Fires an event when any of it's sub gizmos are released from dragging */
  41984. onDragEndObservable: Observable<{}>;
  41985. attachedMesh: Nullable<AbstractMesh>;
  41986. /**
  41987. * Creates a RotationGizmo
  41988. * @param gizmoLayer The utility layer the gizmo will be added to
  41989. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41990. */
  41991. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41992. updateGizmoRotationToMatchAttachedMesh: boolean;
  41993. /**
  41994. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41995. */
  41996. snapDistance: number;
  41997. /**
  41998. * Ratio for the scale of the gizmo (Default: 1)
  41999. */
  42000. scaleRatio: number;
  42001. /**
  42002. * Disposes of the gizmo
  42003. */
  42004. dispose(): void;
  42005. /**
  42006. * CustomMeshes are not supported by this gizmo
  42007. * @param mesh The mesh to replace the default mesh of the gizmo
  42008. */
  42009. setCustomMesh(mesh: Mesh): void;
  42010. }
  42011. }
  42012. declare module BABYLON {
  42013. /**
  42014. * Gizmo that enables dragging a mesh along 3 axis
  42015. */
  42016. export class PositionGizmo extends Gizmo {
  42017. /**
  42018. * Internal gizmo used for interactions on the x axis
  42019. */
  42020. xGizmo: AxisDragGizmo;
  42021. /**
  42022. * Internal gizmo used for interactions on the y axis
  42023. */
  42024. yGizmo: AxisDragGizmo;
  42025. /**
  42026. * Internal gizmo used for interactions on the z axis
  42027. */
  42028. zGizmo: AxisDragGizmo;
  42029. /** Fires an event when any of it's sub gizmos are dragged */
  42030. onDragStartObservable: Observable<{}>;
  42031. /** Fires an event when any of it's sub gizmos are released from dragging */
  42032. onDragEndObservable: Observable<{}>;
  42033. attachedMesh: Nullable<AbstractMesh>;
  42034. /**
  42035. * Creates a PositionGizmo
  42036. * @param gizmoLayer The utility layer the gizmo will be added to
  42037. */
  42038. constructor(gizmoLayer?: UtilityLayerRenderer);
  42039. updateGizmoRotationToMatchAttachedMesh: boolean;
  42040. /**
  42041. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42042. */
  42043. snapDistance: number;
  42044. /**
  42045. * Ratio for the scale of the gizmo (Default: 1)
  42046. */
  42047. scaleRatio: number;
  42048. /**
  42049. * Disposes of the gizmo
  42050. */
  42051. dispose(): void;
  42052. /**
  42053. * CustomMeshes are not supported by this gizmo
  42054. * @param mesh The mesh to replace the default mesh of the gizmo
  42055. */
  42056. setCustomMesh(mesh: Mesh): void;
  42057. }
  42058. }
  42059. declare module BABYLON {
  42060. /**
  42061. * Class containing static functions to help procedurally build meshes
  42062. */
  42063. export class PolyhedronBuilder {
  42064. /**
  42065. * Creates a polyhedron mesh
  42066. * * 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
  42067. * * The parameter `size` (positive float, default 1) sets the polygon size
  42068. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42069. * * 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`
  42070. * * 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
  42071. * * 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)`)
  42072. * * 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
  42073. * * 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
  42074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42075. * * 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
  42076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42077. * @param name defines the name of the mesh
  42078. * @param options defines the options used to create the mesh
  42079. * @param scene defines the hosting scene
  42080. * @returns the polyhedron mesh
  42081. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42082. */
  42083. static CreatePolyhedron(name: string, options: {
  42084. type?: number;
  42085. size?: number;
  42086. sizeX?: number;
  42087. sizeY?: number;
  42088. sizeZ?: number;
  42089. custom?: any;
  42090. faceUV?: Vector4[];
  42091. faceColors?: Color4[];
  42092. flat?: boolean;
  42093. updatable?: boolean;
  42094. sideOrientation?: number;
  42095. frontUVs?: Vector4;
  42096. backUVs?: Vector4;
  42097. }, scene?: Nullable<Scene>): Mesh;
  42098. }
  42099. }
  42100. declare module BABYLON {
  42101. /**
  42102. * Gizmo that enables scaling a mesh along 3 axis
  42103. */
  42104. export class ScaleGizmo extends Gizmo {
  42105. /**
  42106. * Internal gizmo used for interactions on the x axis
  42107. */
  42108. xGizmo: AxisScaleGizmo;
  42109. /**
  42110. * Internal gizmo used for interactions on the y axis
  42111. */
  42112. yGizmo: AxisScaleGizmo;
  42113. /**
  42114. * Internal gizmo used for interactions on the z axis
  42115. */
  42116. zGizmo: AxisScaleGizmo;
  42117. /**
  42118. * Internal gizmo used to scale all axis equally
  42119. */
  42120. uniformScaleGizmo: AxisScaleGizmo;
  42121. /** Fires an event when any of it's sub gizmos are dragged */
  42122. onDragStartObservable: Observable<{}>;
  42123. /** Fires an event when any of it's sub gizmos are released from dragging */
  42124. onDragEndObservable: Observable<{}>;
  42125. attachedMesh: Nullable<AbstractMesh>;
  42126. /**
  42127. * Creates a ScaleGizmo
  42128. * @param gizmoLayer The utility layer the gizmo will be added to
  42129. */
  42130. constructor(gizmoLayer?: UtilityLayerRenderer);
  42131. updateGizmoRotationToMatchAttachedMesh: boolean;
  42132. /**
  42133. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42134. */
  42135. snapDistance: number;
  42136. /**
  42137. * Ratio for the scale of the gizmo (Default: 1)
  42138. */
  42139. scaleRatio: number;
  42140. /**
  42141. * Disposes of the gizmo
  42142. */
  42143. dispose(): void;
  42144. }
  42145. }
  42146. declare module BABYLON {
  42147. /**
  42148. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42149. */
  42150. export class GizmoManager implements IDisposable {
  42151. private scene;
  42152. /**
  42153. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42154. */
  42155. gizmos: {
  42156. positionGizmo: Nullable<PositionGizmo>;
  42157. rotationGizmo: Nullable<RotationGizmo>;
  42158. scaleGizmo: Nullable<ScaleGizmo>;
  42159. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42160. };
  42161. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42162. clearGizmoOnEmptyPointerEvent: boolean;
  42163. /** Fires an event when the manager is attached to a mesh */
  42164. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42165. private _gizmosEnabled;
  42166. private _pointerObserver;
  42167. private _attachedMesh;
  42168. private _boundingBoxColor;
  42169. private _defaultUtilityLayer;
  42170. private _defaultKeepDepthUtilityLayer;
  42171. /**
  42172. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42173. */
  42174. boundingBoxDragBehavior: SixDofDragBehavior;
  42175. /**
  42176. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42177. */
  42178. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42179. /**
  42180. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42181. */
  42182. usePointerToAttachGizmos: boolean;
  42183. /**
  42184. * Instatiates a gizmo manager
  42185. * @param scene the scene to overlay the gizmos on top of
  42186. */
  42187. constructor(scene: Scene);
  42188. /**
  42189. * Attaches a set of gizmos to the specified mesh
  42190. * @param mesh The mesh the gizmo's should be attached to
  42191. */
  42192. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42193. /**
  42194. * If the position gizmo is enabled
  42195. */
  42196. positionGizmoEnabled: boolean;
  42197. /**
  42198. * If the rotation gizmo is enabled
  42199. */
  42200. rotationGizmoEnabled: boolean;
  42201. /**
  42202. * If the scale gizmo is enabled
  42203. */
  42204. scaleGizmoEnabled: boolean;
  42205. /**
  42206. * If the boundingBox gizmo is enabled
  42207. */
  42208. boundingBoxGizmoEnabled: boolean;
  42209. /**
  42210. * Disposes of the gizmo manager
  42211. */
  42212. dispose(): void;
  42213. }
  42214. }
  42215. declare module BABYLON {
  42216. /**
  42217. * A directional light is defined by a direction (what a surprise!).
  42218. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42219. * 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.
  42220. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42221. */
  42222. export class DirectionalLight extends ShadowLight {
  42223. private _shadowFrustumSize;
  42224. /**
  42225. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42226. */
  42227. /**
  42228. * Specifies a fix frustum size for the shadow generation.
  42229. */
  42230. shadowFrustumSize: number;
  42231. private _shadowOrthoScale;
  42232. /**
  42233. * Gets the shadow projection scale against the optimal computed one.
  42234. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42235. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42236. */
  42237. /**
  42238. * Sets the shadow projection scale against the optimal computed one.
  42239. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42240. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42241. */
  42242. shadowOrthoScale: number;
  42243. /**
  42244. * Automatically compute the projection matrix to best fit (including all the casters)
  42245. * on each frame.
  42246. */
  42247. autoUpdateExtends: boolean;
  42248. private _orthoLeft;
  42249. private _orthoRight;
  42250. private _orthoTop;
  42251. private _orthoBottom;
  42252. /**
  42253. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42254. * The directional light is emitted from everywhere in the given direction.
  42255. * It can cast shadows.
  42256. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42257. * @param name The friendly name of the light
  42258. * @param direction The direction of the light
  42259. * @param scene The scene the light belongs to
  42260. */
  42261. constructor(name: string, direction: Vector3, scene: Scene);
  42262. /**
  42263. * Returns the string "DirectionalLight".
  42264. * @return The class name
  42265. */
  42266. getClassName(): string;
  42267. /**
  42268. * Returns the integer 1.
  42269. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42270. */
  42271. getTypeID(): number;
  42272. /**
  42273. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42274. * Returns the DirectionalLight Shadow projection matrix.
  42275. */
  42276. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42277. /**
  42278. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42279. * Returns the DirectionalLight Shadow projection matrix.
  42280. */
  42281. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42282. /**
  42283. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42284. * Returns the DirectionalLight Shadow projection matrix.
  42285. */
  42286. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42287. protected _buildUniformLayout(): void;
  42288. /**
  42289. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42290. * @param effect The effect to update
  42291. * @param lightIndex The index of the light in the effect to update
  42292. * @returns The directional light
  42293. */
  42294. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42295. /**
  42296. * Gets the minZ used for shadow according to both the scene and the light.
  42297. *
  42298. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42299. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42300. * @param activeCamera The camera we are returning the min for
  42301. * @returns the depth min z
  42302. */
  42303. getDepthMinZ(activeCamera: Camera): number;
  42304. /**
  42305. * Gets the maxZ used for shadow according to both the scene and the light.
  42306. *
  42307. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42308. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42309. * @param activeCamera The camera we are returning the max for
  42310. * @returns the depth max z
  42311. */
  42312. getDepthMaxZ(activeCamera: Camera): number;
  42313. /**
  42314. * Prepares the list of defines specific to the light type.
  42315. * @param defines the list of defines
  42316. * @param lightIndex defines the index of the light for the effect
  42317. */
  42318. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42319. }
  42320. }
  42321. declare module BABYLON {
  42322. /**
  42323. * Class containing static functions to help procedurally build meshes
  42324. */
  42325. export class HemisphereBuilder {
  42326. /**
  42327. * Creates a hemisphere mesh
  42328. * @param name defines the name of the mesh
  42329. * @param options defines the options used to create the mesh
  42330. * @param scene defines the hosting scene
  42331. * @returns the hemisphere mesh
  42332. */
  42333. static CreateHemisphere(name: string, options: {
  42334. segments?: number;
  42335. diameter?: number;
  42336. sideOrientation?: number;
  42337. }, scene: any): Mesh;
  42338. }
  42339. }
  42340. declare module BABYLON {
  42341. /**
  42342. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42343. * These values define a cone of light starting from the position, emitting toward the direction.
  42344. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42345. * and the exponent defines the speed of the decay of the light with distance (reach).
  42346. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42347. */
  42348. export class SpotLight extends ShadowLight {
  42349. private _angle;
  42350. private _innerAngle;
  42351. private _cosHalfAngle;
  42352. private _lightAngleScale;
  42353. private _lightAngleOffset;
  42354. /**
  42355. * Gets the cone angle of the spot light in Radians.
  42356. */
  42357. /**
  42358. * Sets the cone angle of the spot light in Radians.
  42359. */
  42360. angle: number;
  42361. /**
  42362. * Only used in gltf falloff mode, this defines the angle where
  42363. * the directional falloff will start before cutting at angle which could be seen
  42364. * as outer angle.
  42365. */
  42366. /**
  42367. * Only used in gltf falloff mode, this defines the angle where
  42368. * the directional falloff will start before cutting at angle which could be seen
  42369. * as outer angle.
  42370. */
  42371. innerAngle: number;
  42372. private _shadowAngleScale;
  42373. /**
  42374. * Allows scaling the angle of the light for shadow generation only.
  42375. */
  42376. /**
  42377. * Allows scaling the angle of the light for shadow generation only.
  42378. */
  42379. shadowAngleScale: number;
  42380. /**
  42381. * The light decay speed with the distance from the emission spot.
  42382. */
  42383. exponent: number;
  42384. private _projectionTextureMatrix;
  42385. /**
  42386. * Allows reading the projecton texture
  42387. */
  42388. readonly projectionTextureMatrix: Matrix;
  42389. protected _projectionTextureLightNear: number;
  42390. /**
  42391. * Gets the near clip of the Spotlight for texture projection.
  42392. */
  42393. /**
  42394. * Sets the near clip of the Spotlight for texture projection.
  42395. */
  42396. projectionTextureLightNear: number;
  42397. protected _projectionTextureLightFar: number;
  42398. /**
  42399. * Gets the far clip of the Spotlight for texture projection.
  42400. */
  42401. /**
  42402. * Sets the far clip of the Spotlight for texture projection.
  42403. */
  42404. projectionTextureLightFar: number;
  42405. protected _projectionTextureUpDirection: Vector3;
  42406. /**
  42407. * Gets the Up vector of the Spotlight for texture projection.
  42408. */
  42409. /**
  42410. * Sets the Up vector of the Spotlight for texture projection.
  42411. */
  42412. projectionTextureUpDirection: Vector3;
  42413. private _projectionTexture;
  42414. /**
  42415. * Gets the projection texture of the light.
  42416. */
  42417. /**
  42418. * Sets the projection texture of the light.
  42419. */
  42420. projectionTexture: Nullable<BaseTexture>;
  42421. private _projectionTextureViewLightDirty;
  42422. private _projectionTextureProjectionLightDirty;
  42423. private _projectionTextureDirty;
  42424. private _projectionTextureViewTargetVector;
  42425. private _projectionTextureViewLightMatrix;
  42426. private _projectionTextureProjectionLightMatrix;
  42427. private _projectionTextureScalingMatrix;
  42428. /**
  42429. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42430. * It can cast shadows.
  42431. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42432. * @param name The light friendly name
  42433. * @param position The position of the spot light in the scene
  42434. * @param direction The direction of the light in the scene
  42435. * @param angle The cone angle of the light in Radians
  42436. * @param exponent The light decay speed with the distance from the emission spot
  42437. * @param scene The scene the lights belongs to
  42438. */
  42439. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42440. /**
  42441. * Returns the string "SpotLight".
  42442. * @returns the class name
  42443. */
  42444. getClassName(): string;
  42445. /**
  42446. * Returns the integer 2.
  42447. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42448. */
  42449. getTypeID(): number;
  42450. /**
  42451. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42452. */
  42453. protected _setDirection(value: Vector3): void;
  42454. /**
  42455. * Overrides the position setter to recompute the projection texture view light Matrix.
  42456. */
  42457. protected _setPosition(value: Vector3): void;
  42458. /**
  42459. * 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.
  42460. * Returns the SpotLight.
  42461. */
  42462. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42463. protected _computeProjectionTextureViewLightMatrix(): void;
  42464. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42465. /**
  42466. * Main function for light texture projection matrix computing.
  42467. */
  42468. protected _computeProjectionTextureMatrix(): void;
  42469. protected _buildUniformLayout(): void;
  42470. private _computeAngleValues;
  42471. /**
  42472. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42473. * @param effect The effect to update
  42474. * @param lightIndex The index of the light in the effect to update
  42475. * @returns The spot light
  42476. */
  42477. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42478. /**
  42479. * Disposes the light and the associated resources.
  42480. */
  42481. dispose(): void;
  42482. /**
  42483. * Prepares the list of defines specific to the light type.
  42484. * @param defines the list of defines
  42485. * @param lightIndex defines the index of the light for the effect
  42486. */
  42487. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42488. }
  42489. }
  42490. declare module BABYLON {
  42491. /**
  42492. * Gizmo that enables viewing a light
  42493. */
  42494. export class LightGizmo extends Gizmo {
  42495. private _lightMesh;
  42496. private _material;
  42497. /**
  42498. * Creates a LightGizmo
  42499. * @param gizmoLayer The utility layer the gizmo will be added to
  42500. */
  42501. constructor(gizmoLayer?: UtilityLayerRenderer);
  42502. private _light;
  42503. /**
  42504. * The light that the gizmo is attached to
  42505. */
  42506. light: Nullable<Light>;
  42507. /**
  42508. * @hidden
  42509. * Updates the gizmo to match the attached mesh's position/rotation
  42510. */
  42511. protected _update(): void;
  42512. private static _Scale;
  42513. /**
  42514. * Creates the lines for a light mesh
  42515. */
  42516. private static _createLightLines;
  42517. private static _CreateHemisphericLightMesh;
  42518. private static _CreatePointLightMesh;
  42519. private static _CreateSpotLightMesh;
  42520. private static _CreateDirectionalLightMesh;
  42521. }
  42522. }
  42523. declare module BABYLON {
  42524. /** @hidden */
  42525. export var backgroundFragmentDeclaration: {
  42526. name: string;
  42527. shader: string;
  42528. };
  42529. }
  42530. declare module BABYLON {
  42531. /** @hidden */
  42532. export var backgroundUboDeclaration: {
  42533. name: string;
  42534. shader: string;
  42535. };
  42536. }
  42537. declare module BABYLON {
  42538. /** @hidden */
  42539. export var backgroundPixelShader: {
  42540. name: string;
  42541. shader: string;
  42542. };
  42543. }
  42544. declare module BABYLON {
  42545. /** @hidden */
  42546. export var backgroundVertexDeclaration: {
  42547. name: string;
  42548. shader: string;
  42549. };
  42550. }
  42551. declare module BABYLON {
  42552. /** @hidden */
  42553. export var backgroundVertexShader: {
  42554. name: string;
  42555. shader: string;
  42556. };
  42557. }
  42558. declare module BABYLON {
  42559. /**
  42560. * Background material used to create an efficient environement around your scene.
  42561. */
  42562. export class BackgroundMaterial extends PushMaterial {
  42563. /**
  42564. * Standard reflectance value at parallel view angle.
  42565. */
  42566. static StandardReflectance0: number;
  42567. /**
  42568. * Standard reflectance value at grazing angle.
  42569. */
  42570. static StandardReflectance90: number;
  42571. protected _primaryColor: Color3;
  42572. /**
  42573. * Key light Color (multiply against the environement texture)
  42574. */
  42575. primaryColor: Color3;
  42576. protected __perceptualColor: Nullable<Color3>;
  42577. /**
  42578. * Experimental Internal Use Only.
  42579. *
  42580. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42581. * This acts as a helper to set the primary color to a more "human friendly" value.
  42582. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42583. * output color as close as possible from the chosen value.
  42584. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42585. * part of lighting setup.)
  42586. */ perceptualColor: Nullable<Color3>;
  42587. protected _primaryColorShadowLevel: float;
  42588. /**
  42589. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42590. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42591. */
  42592. primaryColorShadowLevel: float;
  42593. protected _primaryColorHighlightLevel: float;
  42594. /**
  42595. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42596. * The primary color is used at the level chosen to define what the white area would look.
  42597. */
  42598. primaryColorHighlightLevel: float;
  42599. protected _reflectionTexture: Nullable<BaseTexture>;
  42600. /**
  42601. * Reflection Texture used in the material.
  42602. * Should be author in a specific way for the best result (refer to the documentation).
  42603. */
  42604. reflectionTexture: Nullable<BaseTexture>;
  42605. protected _reflectionBlur: float;
  42606. /**
  42607. * Reflection Texture level of blur.
  42608. *
  42609. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42610. * texture twice.
  42611. */
  42612. reflectionBlur: float;
  42613. protected _diffuseTexture: Nullable<BaseTexture>;
  42614. /**
  42615. * Diffuse Texture used in the material.
  42616. * Should be author in a specific way for the best result (refer to the documentation).
  42617. */
  42618. diffuseTexture: Nullable<BaseTexture>;
  42619. protected _shadowLights: Nullable<IShadowLight[]>;
  42620. /**
  42621. * Specify the list of lights casting shadow on the material.
  42622. * All scene shadow lights will be included if null.
  42623. */
  42624. shadowLights: Nullable<IShadowLight[]>;
  42625. protected _shadowLevel: float;
  42626. /**
  42627. * Helps adjusting the shadow to a softer level if required.
  42628. * 0 means black shadows and 1 means no shadows.
  42629. */
  42630. shadowLevel: float;
  42631. protected _sceneCenter: Vector3;
  42632. /**
  42633. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42634. * It is usually zero but might be interesting to modify according to your setup.
  42635. */
  42636. sceneCenter: Vector3;
  42637. protected _opacityFresnel: boolean;
  42638. /**
  42639. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42640. * This helps ensuring a nice transition when the camera goes under the ground.
  42641. */
  42642. opacityFresnel: boolean;
  42643. protected _reflectionFresnel: boolean;
  42644. /**
  42645. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42646. * This helps adding a mirror texture on the ground.
  42647. */
  42648. reflectionFresnel: boolean;
  42649. protected _reflectionFalloffDistance: number;
  42650. /**
  42651. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42652. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42653. */
  42654. reflectionFalloffDistance: number;
  42655. protected _reflectionAmount: number;
  42656. /**
  42657. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42658. */
  42659. reflectionAmount: number;
  42660. protected _reflectionReflectance0: number;
  42661. /**
  42662. * This specifies the weight of the reflection at grazing angle.
  42663. */
  42664. reflectionReflectance0: number;
  42665. protected _reflectionReflectance90: number;
  42666. /**
  42667. * This specifies the weight of the reflection at a perpendicular point of view.
  42668. */
  42669. reflectionReflectance90: number;
  42670. /**
  42671. * Sets the reflection reflectance fresnel values according to the default standard
  42672. * empirically know to work well :-)
  42673. */
  42674. reflectionStandardFresnelWeight: number;
  42675. protected _useRGBColor: boolean;
  42676. /**
  42677. * Helps to directly use the maps channels instead of their level.
  42678. */
  42679. useRGBColor: boolean;
  42680. protected _enableNoise: boolean;
  42681. /**
  42682. * This helps reducing the banding effect that could occur on the background.
  42683. */
  42684. enableNoise: boolean;
  42685. /**
  42686. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42687. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42688. * Recommended to be keep at 1.0 except for special cases.
  42689. */
  42690. fovMultiplier: number;
  42691. private _fovMultiplier;
  42692. /**
  42693. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42694. */
  42695. useEquirectangularFOV: boolean;
  42696. private _maxSimultaneousLights;
  42697. /**
  42698. * Number of Simultaneous lights allowed on the material.
  42699. */
  42700. maxSimultaneousLights: int;
  42701. /**
  42702. * Default configuration related to image processing available in the Background Material.
  42703. */
  42704. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42705. /**
  42706. * Keep track of the image processing observer to allow dispose and replace.
  42707. */
  42708. private _imageProcessingObserver;
  42709. /**
  42710. * Attaches a new image processing configuration to the PBR Material.
  42711. * @param configuration (if null the scene configuration will be use)
  42712. */
  42713. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42714. /**
  42715. * Gets the image processing configuration used either in this material.
  42716. */
  42717. /**
  42718. * Sets the Default image processing configuration used either in the this material.
  42719. *
  42720. * If sets to null, the scene one is in use.
  42721. */
  42722. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42723. /**
  42724. * Gets wether the color curves effect is enabled.
  42725. */
  42726. /**
  42727. * Sets wether the color curves effect is enabled.
  42728. */
  42729. cameraColorCurvesEnabled: boolean;
  42730. /**
  42731. * Gets wether the color grading effect is enabled.
  42732. */
  42733. /**
  42734. * Gets wether the color grading effect is enabled.
  42735. */
  42736. cameraColorGradingEnabled: boolean;
  42737. /**
  42738. * Gets wether tonemapping is enabled or not.
  42739. */
  42740. /**
  42741. * Sets wether tonemapping is enabled or not
  42742. */
  42743. cameraToneMappingEnabled: boolean;
  42744. /**
  42745. * The camera exposure used on this material.
  42746. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42747. * This corresponds to a photographic exposure.
  42748. */
  42749. /**
  42750. * The camera exposure used on this material.
  42751. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42752. * This corresponds to a photographic exposure.
  42753. */
  42754. cameraExposure: float;
  42755. /**
  42756. * Gets The camera contrast used on this material.
  42757. */
  42758. /**
  42759. * Sets The camera contrast used on this material.
  42760. */
  42761. cameraContrast: float;
  42762. /**
  42763. * Gets the Color Grading 2D Lookup Texture.
  42764. */
  42765. /**
  42766. * Sets the Color Grading 2D Lookup Texture.
  42767. */
  42768. cameraColorGradingTexture: Nullable<BaseTexture>;
  42769. /**
  42770. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42771. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42772. * 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;
  42773. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42774. */
  42775. /**
  42776. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42777. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42778. * 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;
  42779. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42780. */
  42781. cameraColorCurves: Nullable<ColorCurves>;
  42782. /**
  42783. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42784. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42785. */
  42786. switchToBGR: boolean;
  42787. private _renderTargets;
  42788. private _reflectionControls;
  42789. private _white;
  42790. private _primaryShadowColor;
  42791. private _primaryHighlightColor;
  42792. /**
  42793. * Instantiates a Background Material in the given scene
  42794. * @param name The friendly name of the material
  42795. * @param scene The scene to add the material to
  42796. */
  42797. constructor(name: string, scene: Scene);
  42798. /**
  42799. * Gets a boolean indicating that current material needs to register RTT
  42800. */
  42801. readonly hasRenderTargetTextures: boolean;
  42802. /**
  42803. * The entire material has been created in order to prevent overdraw.
  42804. * @returns false
  42805. */
  42806. needAlphaTesting(): boolean;
  42807. /**
  42808. * The entire material has been created in order to prevent overdraw.
  42809. * @returns true if blending is enable
  42810. */
  42811. needAlphaBlending(): boolean;
  42812. /**
  42813. * Checks wether the material is ready to be rendered for a given mesh.
  42814. * @param mesh The mesh to render
  42815. * @param subMesh The submesh to check against
  42816. * @param useInstances Specify wether or not the material is used with instances
  42817. * @returns true if all the dependencies are ready (Textures, Effects...)
  42818. */
  42819. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42820. /**
  42821. * Compute the primary color according to the chosen perceptual color.
  42822. */
  42823. private _computePrimaryColorFromPerceptualColor;
  42824. /**
  42825. * Compute the highlights and shadow colors according to their chosen levels.
  42826. */
  42827. private _computePrimaryColors;
  42828. /**
  42829. * Build the uniform buffer used in the material.
  42830. */
  42831. buildUniformLayout(): void;
  42832. /**
  42833. * Unbind the material.
  42834. */
  42835. unbind(): void;
  42836. /**
  42837. * Bind only the world matrix to the material.
  42838. * @param world The world matrix to bind.
  42839. */
  42840. bindOnlyWorldMatrix(world: Matrix): void;
  42841. /**
  42842. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42843. * @param world The world matrix to bind.
  42844. * @param subMesh The submesh to bind for.
  42845. */
  42846. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42847. /**
  42848. * Dispose the material.
  42849. * @param forceDisposeEffect Force disposal of the associated effect.
  42850. * @param forceDisposeTextures Force disposal of the associated textures.
  42851. */
  42852. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42853. /**
  42854. * Clones the material.
  42855. * @param name The cloned name.
  42856. * @returns The cloned material.
  42857. */
  42858. clone(name: string): BackgroundMaterial;
  42859. /**
  42860. * Serializes the current material to its JSON representation.
  42861. * @returns The JSON representation.
  42862. */
  42863. serialize(): any;
  42864. /**
  42865. * Gets the class name of the material
  42866. * @returns "BackgroundMaterial"
  42867. */
  42868. getClassName(): string;
  42869. /**
  42870. * Parse a JSON input to create back a background material.
  42871. * @param source The JSON data to parse
  42872. * @param scene The scene to create the parsed material in
  42873. * @param rootUrl The root url of the assets the material depends upon
  42874. * @returns the instantiated BackgroundMaterial.
  42875. */
  42876. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42877. }
  42878. }
  42879. declare module BABYLON {
  42880. /**
  42881. * Represents the different options available during the creation of
  42882. * a Environment helper.
  42883. *
  42884. * This can control the default ground, skybox and image processing setup of your scene.
  42885. */
  42886. export interface IEnvironmentHelperOptions {
  42887. /**
  42888. * Specifies wether or not to create a ground.
  42889. * True by default.
  42890. */
  42891. createGround: boolean;
  42892. /**
  42893. * Specifies the ground size.
  42894. * 15 by default.
  42895. */
  42896. groundSize: number;
  42897. /**
  42898. * The texture used on the ground for the main color.
  42899. * Comes from the BabylonJS CDN by default.
  42900. *
  42901. * Remarks: Can be either a texture or a url.
  42902. */
  42903. groundTexture: string | BaseTexture;
  42904. /**
  42905. * The color mixed in the ground texture by default.
  42906. * BabylonJS clearColor by default.
  42907. */
  42908. groundColor: Color3;
  42909. /**
  42910. * Specifies the ground opacity.
  42911. * 1 by default.
  42912. */
  42913. groundOpacity: number;
  42914. /**
  42915. * Enables the ground to receive shadows.
  42916. * True by default.
  42917. */
  42918. enableGroundShadow: boolean;
  42919. /**
  42920. * Helps preventing the shadow to be fully black on the ground.
  42921. * 0.5 by default.
  42922. */
  42923. groundShadowLevel: number;
  42924. /**
  42925. * Creates a mirror texture attach to the ground.
  42926. * false by default.
  42927. */
  42928. enableGroundMirror: boolean;
  42929. /**
  42930. * Specifies the ground mirror size ratio.
  42931. * 0.3 by default as the default kernel is 64.
  42932. */
  42933. groundMirrorSizeRatio: number;
  42934. /**
  42935. * Specifies the ground mirror blur kernel size.
  42936. * 64 by default.
  42937. */
  42938. groundMirrorBlurKernel: number;
  42939. /**
  42940. * Specifies the ground mirror visibility amount.
  42941. * 1 by default
  42942. */
  42943. groundMirrorAmount: number;
  42944. /**
  42945. * Specifies the ground mirror reflectance weight.
  42946. * This uses the standard weight of the background material to setup the fresnel effect
  42947. * of the mirror.
  42948. * 1 by default.
  42949. */
  42950. groundMirrorFresnelWeight: number;
  42951. /**
  42952. * Specifies the ground mirror Falloff distance.
  42953. * This can helps reducing the size of the reflection.
  42954. * 0 by Default.
  42955. */
  42956. groundMirrorFallOffDistance: number;
  42957. /**
  42958. * Specifies the ground mirror texture type.
  42959. * Unsigned Int by Default.
  42960. */
  42961. groundMirrorTextureType: number;
  42962. /**
  42963. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42964. * the shown objects.
  42965. */
  42966. groundYBias: number;
  42967. /**
  42968. * Specifies wether or not to create a skybox.
  42969. * True by default.
  42970. */
  42971. createSkybox: boolean;
  42972. /**
  42973. * Specifies the skybox size.
  42974. * 20 by default.
  42975. */
  42976. skyboxSize: number;
  42977. /**
  42978. * The texture used on the skybox for the main color.
  42979. * Comes from the BabylonJS CDN by default.
  42980. *
  42981. * Remarks: Can be either a texture or a url.
  42982. */
  42983. skyboxTexture: string | BaseTexture;
  42984. /**
  42985. * The color mixed in the skybox texture by default.
  42986. * BabylonJS clearColor by default.
  42987. */
  42988. skyboxColor: Color3;
  42989. /**
  42990. * The background rotation around the Y axis of the scene.
  42991. * This helps aligning the key lights of your scene with the background.
  42992. * 0 by default.
  42993. */
  42994. backgroundYRotation: number;
  42995. /**
  42996. * Compute automatically the size of the elements to best fit with the scene.
  42997. */
  42998. sizeAuto: boolean;
  42999. /**
  43000. * Default position of the rootMesh if autoSize is not true.
  43001. */
  43002. rootPosition: Vector3;
  43003. /**
  43004. * Sets up the image processing in the scene.
  43005. * true by default.
  43006. */
  43007. setupImageProcessing: boolean;
  43008. /**
  43009. * The texture used as your environment texture in the scene.
  43010. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43011. *
  43012. * Remarks: Can be either a texture or a url.
  43013. */
  43014. environmentTexture: string | BaseTexture;
  43015. /**
  43016. * The value of the exposure to apply to the scene.
  43017. * 0.6 by default if setupImageProcessing is true.
  43018. */
  43019. cameraExposure: number;
  43020. /**
  43021. * The value of the contrast to apply to the scene.
  43022. * 1.6 by default if setupImageProcessing is true.
  43023. */
  43024. cameraContrast: number;
  43025. /**
  43026. * Specifies wether or not tonemapping should be enabled in the scene.
  43027. * true by default if setupImageProcessing is true.
  43028. */
  43029. toneMappingEnabled: boolean;
  43030. }
  43031. /**
  43032. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43033. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43034. * It also helps with the default setup of your imageProcessing configuration.
  43035. */
  43036. export class EnvironmentHelper {
  43037. /**
  43038. * Default ground texture URL.
  43039. */
  43040. private static _groundTextureCDNUrl;
  43041. /**
  43042. * Default skybox texture URL.
  43043. */
  43044. private static _skyboxTextureCDNUrl;
  43045. /**
  43046. * Default environment texture URL.
  43047. */
  43048. private static _environmentTextureCDNUrl;
  43049. /**
  43050. * Creates the default options for the helper.
  43051. */
  43052. private static _getDefaultOptions;
  43053. private _rootMesh;
  43054. /**
  43055. * Gets the root mesh created by the helper.
  43056. */
  43057. readonly rootMesh: Mesh;
  43058. private _skybox;
  43059. /**
  43060. * Gets the skybox created by the helper.
  43061. */
  43062. readonly skybox: Nullable<Mesh>;
  43063. private _skyboxTexture;
  43064. /**
  43065. * Gets the skybox texture created by the helper.
  43066. */
  43067. readonly skyboxTexture: Nullable<BaseTexture>;
  43068. private _skyboxMaterial;
  43069. /**
  43070. * Gets the skybox material created by the helper.
  43071. */
  43072. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43073. private _ground;
  43074. /**
  43075. * Gets the ground mesh created by the helper.
  43076. */
  43077. readonly ground: Nullable<Mesh>;
  43078. private _groundTexture;
  43079. /**
  43080. * Gets the ground texture created by the helper.
  43081. */
  43082. readonly groundTexture: Nullable<BaseTexture>;
  43083. private _groundMirror;
  43084. /**
  43085. * Gets the ground mirror created by the helper.
  43086. */
  43087. readonly groundMirror: Nullable<MirrorTexture>;
  43088. /**
  43089. * Gets the ground mirror render list to helps pushing the meshes
  43090. * you wish in the ground reflection.
  43091. */
  43092. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43093. private _groundMaterial;
  43094. /**
  43095. * Gets the ground material created by the helper.
  43096. */
  43097. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43098. /**
  43099. * Stores the creation options.
  43100. */
  43101. private readonly _scene;
  43102. private _options;
  43103. /**
  43104. * This observable will be notified with any error during the creation of the environment,
  43105. * mainly texture creation errors.
  43106. */
  43107. onErrorObservable: Observable<{
  43108. message?: string;
  43109. exception?: any;
  43110. }>;
  43111. /**
  43112. * constructor
  43113. * @param options Defines the options we want to customize the helper
  43114. * @param scene The scene to add the material to
  43115. */
  43116. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43117. /**
  43118. * Updates the background according to the new options
  43119. * @param options
  43120. */
  43121. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43122. /**
  43123. * Sets the primary color of all the available elements.
  43124. * @param color the main color to affect to the ground and the background
  43125. */
  43126. setMainColor(color: Color3): void;
  43127. /**
  43128. * Setup the image processing according to the specified options.
  43129. */
  43130. private _setupImageProcessing;
  43131. /**
  43132. * Setup the environment texture according to the specified options.
  43133. */
  43134. private _setupEnvironmentTexture;
  43135. /**
  43136. * Setup the background according to the specified options.
  43137. */
  43138. private _setupBackground;
  43139. /**
  43140. * Get the scene sizes according to the setup.
  43141. */
  43142. private _getSceneSize;
  43143. /**
  43144. * Setup the ground according to the specified options.
  43145. */
  43146. private _setupGround;
  43147. /**
  43148. * Setup the ground material according to the specified options.
  43149. */
  43150. private _setupGroundMaterial;
  43151. /**
  43152. * Setup the ground diffuse texture according to the specified options.
  43153. */
  43154. private _setupGroundDiffuseTexture;
  43155. /**
  43156. * Setup the ground mirror texture according to the specified options.
  43157. */
  43158. private _setupGroundMirrorTexture;
  43159. /**
  43160. * Setup the ground to receive the mirror texture.
  43161. */
  43162. private _setupMirrorInGroundMaterial;
  43163. /**
  43164. * Setup the skybox according to the specified options.
  43165. */
  43166. private _setupSkybox;
  43167. /**
  43168. * Setup the skybox material according to the specified options.
  43169. */
  43170. private _setupSkyboxMaterial;
  43171. /**
  43172. * Setup the skybox reflection texture according to the specified options.
  43173. */
  43174. private _setupSkyboxReflectionTexture;
  43175. private _errorHandler;
  43176. /**
  43177. * Dispose all the elements created by the Helper.
  43178. */
  43179. dispose(): void;
  43180. }
  43181. }
  43182. declare module BABYLON {
  43183. /**
  43184. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43185. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43186. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43187. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43188. */
  43189. export class PhotoDome extends TransformNode {
  43190. private _useDirectMapping;
  43191. /**
  43192. * The texture being displayed on the sphere
  43193. */
  43194. protected _photoTexture: Texture;
  43195. /**
  43196. * Gets or sets the texture being displayed on the sphere
  43197. */
  43198. photoTexture: Texture;
  43199. /**
  43200. * Observable raised when an error occured while loading the 360 image
  43201. */
  43202. onLoadErrorObservable: Observable<string>;
  43203. /**
  43204. * The skybox material
  43205. */
  43206. protected _material: BackgroundMaterial;
  43207. /**
  43208. * The surface used for the skybox
  43209. */
  43210. protected _mesh: Mesh;
  43211. /**
  43212. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43213. * Also see the options.resolution property.
  43214. */
  43215. fovMultiplier: number;
  43216. /**
  43217. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43218. * @param name Element's name, child elements will append suffixes for their own names.
  43219. * @param urlsOfPhoto defines the url of the photo to display
  43220. * @param options defines an object containing optional or exposed sub element properties
  43221. * @param onError defines a callback called when an error occured while loading the texture
  43222. */
  43223. constructor(name: string, urlOfPhoto: string, options: {
  43224. resolution?: number;
  43225. size?: number;
  43226. useDirectMapping?: boolean;
  43227. faceForward?: boolean;
  43228. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43229. /**
  43230. * Releases resources associated with this node.
  43231. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43232. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43233. */
  43234. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43235. }
  43236. }
  43237. declare module BABYLON {
  43238. /** @hidden */
  43239. export var rgbdDecodePixelShader: {
  43240. name: string;
  43241. shader: string;
  43242. };
  43243. }
  43244. declare module BABYLON {
  43245. /**
  43246. * Class used to host texture specific utilities
  43247. */
  43248. export class BRDFTextureTools {
  43249. /**
  43250. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43251. * @param texture the texture to expand.
  43252. */
  43253. private static _ExpandDefaultBRDFTexture;
  43254. /**
  43255. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43256. * @param scene defines the hosting scene
  43257. * @returns the environment BRDF texture
  43258. */
  43259. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43260. private static _environmentBRDFBase64Texture;
  43261. }
  43262. }
  43263. declare module BABYLON {
  43264. /**
  43265. * @hidden
  43266. */
  43267. export interface IMaterialClearCoatDefines {
  43268. CLEARCOAT: boolean;
  43269. CLEARCOAT_DEFAULTIOR: boolean;
  43270. CLEARCOAT_TEXTURE: boolean;
  43271. CLEARCOAT_TEXTUREDIRECTUV: number;
  43272. CLEARCOAT_BUMP: boolean;
  43273. CLEARCOAT_BUMPDIRECTUV: number;
  43274. CLEARCOAT_TINT: boolean;
  43275. CLEARCOAT_TINT_TEXTURE: boolean;
  43276. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43277. /** @hidden */ areTexturesDirty: boolean;
  43278. }
  43279. /**
  43280. * Define the code related to the clear coat parameters of the pbr material.
  43281. */
  43282. export class PBRClearCoatConfiguration {
  43283. /**
  43284. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43285. * The default fits with a polyurethane material.
  43286. */
  43287. private static readonly _DefaultIndiceOfRefraction;
  43288. private _isEnabled;
  43289. /**
  43290. * Defines if the clear coat is enabled in the material.
  43291. */
  43292. isEnabled: boolean;
  43293. /**
  43294. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43295. */
  43296. intensity: number;
  43297. /**
  43298. * Defines the clear coat layer roughness.
  43299. */
  43300. roughness: number;
  43301. private _indiceOfRefraction;
  43302. /**
  43303. * Defines the indice of refraction of the clear coat.
  43304. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43305. * The default fits with a polyurethane material.
  43306. * Changing the default value is more performance intensive.
  43307. */
  43308. indiceOfRefraction: number;
  43309. private _texture;
  43310. /**
  43311. * Stores the clear coat values in a texture.
  43312. */
  43313. texture: Nullable<BaseTexture>;
  43314. private _bumpTexture;
  43315. /**
  43316. * Define the clear coat specific bump texture.
  43317. */
  43318. bumpTexture: Nullable<BaseTexture>;
  43319. private _isTintEnabled;
  43320. /**
  43321. * Defines if the clear coat tint is enabled in the material.
  43322. */
  43323. isTintEnabled: boolean;
  43324. /**
  43325. * Defines the clear coat tint of the material.
  43326. * This is only use if tint is enabled
  43327. */
  43328. tintColor: Color3;
  43329. /**
  43330. * Defines the distance at which the tint color should be found in the
  43331. * clear coat media.
  43332. * This is only use if tint is enabled
  43333. */
  43334. tintColorAtDistance: number;
  43335. /**
  43336. * Defines the clear coat layer thickness.
  43337. * This is only use if tint is enabled
  43338. */
  43339. tintThickness: number;
  43340. private _tintTexture;
  43341. /**
  43342. * Stores the clear tint values in a texture.
  43343. * rgb is tint
  43344. * a is a thickness factor
  43345. */
  43346. tintTexture: Nullable<BaseTexture>;
  43347. /** @hidden */
  43348. private _internalMarkAllSubMeshesAsTexturesDirty;
  43349. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43350. /**
  43351. * Instantiate a new istance of clear coat configuration.
  43352. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43353. */
  43354. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43355. /**
  43356. * Gets wehter the submesh is ready to be used or not.
  43357. * @param defines the list of "defines" to update.
  43358. * @param scene defines the scene the material belongs to.
  43359. * @param engine defines the engine the material belongs to.
  43360. * @param disableBumpMap defines wether the material disables bump or not.
  43361. * @returns - boolean indicating that the submesh is ready or not.
  43362. */
  43363. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43364. /**
  43365. * Checks to see if a texture is used in the material.
  43366. * @param defines the list of "defines" to update.
  43367. * @param scene defines the scene to the material belongs to.
  43368. */
  43369. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43370. /**
  43371. * Binds the material data.
  43372. * @param uniformBuffer defines the Uniform buffer to fill in.
  43373. * @param scene defines the scene the material belongs to.
  43374. * @param engine defines the engine the material belongs to.
  43375. * @param disableBumpMap defines wether the material disables bump or not.
  43376. * @param isFrozen defines wether the material is frozen or not.
  43377. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43378. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43379. */
  43380. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43381. /**
  43382. * Checks to see if a texture is used in the material.
  43383. * @param texture - Base texture to use.
  43384. * @returns - Boolean specifying if a texture is used in the material.
  43385. */
  43386. hasTexture(texture: BaseTexture): boolean;
  43387. /**
  43388. * Returns an array of the actively used textures.
  43389. * @param activeTextures Array of BaseTextures
  43390. */
  43391. getActiveTextures(activeTextures: BaseTexture[]): void;
  43392. /**
  43393. * Returns the animatable textures.
  43394. * @param animatables Array of animatable textures.
  43395. */
  43396. getAnimatables(animatables: IAnimatable[]): void;
  43397. /**
  43398. * Disposes the resources of the material.
  43399. * @param forceDisposeTextures - Forces the disposal of all textures.
  43400. */
  43401. dispose(forceDisposeTextures?: boolean): void;
  43402. /**
  43403. * Get the current class name of the texture useful for serialization or dynamic coding.
  43404. * @returns "PBRClearCoatConfiguration"
  43405. */
  43406. getClassName(): string;
  43407. /**
  43408. * Add fallbacks to the effect fallbacks list.
  43409. * @param defines defines the Base texture to use.
  43410. * @param fallbacks defines the current fallback list.
  43411. * @param currentRank defines the current fallback rank.
  43412. * @returns the new fallback rank.
  43413. */
  43414. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43415. /**
  43416. * Add the required uniforms to the current list.
  43417. * @param uniforms defines the current uniform list.
  43418. */
  43419. static AddUniforms(uniforms: string[]): void;
  43420. /**
  43421. * Add the required samplers to the current list.
  43422. * @param samplers defines the current sampler list.
  43423. */
  43424. static AddSamplers(samplers: string[]): void;
  43425. /**
  43426. * Add the required uniforms to the current buffer.
  43427. * @param uniformBuffer defines the current uniform buffer.
  43428. */
  43429. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43430. /**
  43431. * Makes a duplicate of the current configuration into another one.
  43432. * @param clearCoatConfiguration define the config where to copy the info
  43433. */
  43434. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43435. /**
  43436. * Serializes this clear coat configuration.
  43437. * @returns - An object with the serialized config.
  43438. */
  43439. serialize(): any;
  43440. /**
  43441. * Parses a Clear Coat Configuration from a serialized object.
  43442. * @param source - Serialized object.
  43443. */
  43444. parse(source: any): void;
  43445. }
  43446. }
  43447. declare module BABYLON {
  43448. /**
  43449. * @hidden
  43450. */
  43451. export interface IMaterialAnisotropicDefines {
  43452. ANISOTROPIC: boolean;
  43453. ANISOTROPIC_TEXTURE: boolean;
  43454. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43455. MAINUV1: boolean; areTexturesDirty: boolean; needUVs: boolean;
  43456. }
  43457. /**
  43458. * Define the code related to the anisotropic parameters of the pbr material.
  43459. */
  43460. export class PBRAnisotropicConfiguration {
  43461. private _isEnabled;
  43462. /**
  43463. * Defines if the anisotropy is enabled in the material.
  43464. */
  43465. isEnabled: boolean;
  43466. /**
  43467. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43468. */
  43469. intensity: number;
  43470. /**
  43471. * Defines if the effect is along the tangents, bitangents or in between.
  43472. * By default, the effect is "strectching" the highlights along the tangents.
  43473. */
  43474. direction: Vector2;
  43475. private _texture;
  43476. /**
  43477. * Stores the anisotropy values in a texture.
  43478. * rg is direction (like normal from -1 to 1)
  43479. * b is a intensity
  43480. */
  43481. texture: Nullable<BaseTexture>;
  43482. /** @hidden */
  43483. private _internalMarkAllSubMeshesAsTexturesDirty;
  43484. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43485. /**
  43486. * Instantiate a new istance of anisotropy configuration.
  43487. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43488. */
  43489. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43490. /**
  43491. * Specifies that the submesh is ready to be used.
  43492. * @param defines the list of "defines" to update.
  43493. * @param scene defines the scene the material belongs to.
  43494. * @returns - boolean indicating that the submesh is ready or not.
  43495. */
  43496. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43497. /**
  43498. * Checks to see if a texture is used in the material.
  43499. * @param defines the list of "defines" to update.
  43500. * @param mesh the mesh we are preparing the defines for.
  43501. * @param scene defines the scene the material belongs to.
  43502. */
  43503. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43504. /**
  43505. * Binds the material data.
  43506. * @param uniformBuffer defines the Uniform buffer to fill in.
  43507. * @param scene defines the scene the material belongs to.
  43508. * @param isFrozen defines wether the material is frozen or not.
  43509. */
  43510. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43511. /**
  43512. * Checks to see if a texture is used in the material.
  43513. * @param texture - Base texture to use.
  43514. * @returns - Boolean specifying if a texture is used in the material.
  43515. */
  43516. hasTexture(texture: BaseTexture): boolean;
  43517. /**
  43518. * Returns an array of the actively used textures.
  43519. * @param activeTextures Array of BaseTextures
  43520. */
  43521. getActiveTextures(activeTextures: BaseTexture[]): void;
  43522. /**
  43523. * Returns the animatable textures.
  43524. * @param animatables Array of animatable textures.
  43525. */
  43526. getAnimatables(animatables: IAnimatable[]): void;
  43527. /**
  43528. * Disposes the resources of the material.
  43529. * @param forceDisposeTextures - Forces the disposal of all textures.
  43530. */
  43531. dispose(forceDisposeTextures?: boolean): void;
  43532. /**
  43533. * Get the current class name of the texture useful for serialization or dynamic coding.
  43534. * @returns "PBRAnisotropicConfiguration"
  43535. */
  43536. getClassName(): string;
  43537. /**
  43538. * Add fallbacks to the effect fallbacks list.
  43539. * @param defines defines the Base texture to use.
  43540. * @param fallbacks defines the current fallback list.
  43541. * @param currentRank defines the current fallback rank.
  43542. * @returns the new fallback rank.
  43543. */
  43544. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43545. /**
  43546. * Add the required uniforms to the current list.
  43547. * @param uniforms defines the current uniform list.
  43548. */
  43549. static AddUniforms(uniforms: string[]): void;
  43550. /**
  43551. * Add the required uniforms to the current buffer.
  43552. * @param uniformBuffer defines the current uniform buffer.
  43553. */
  43554. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43555. /**
  43556. * Add the required samplers to the current list.
  43557. * @param samplers defines the current sampler list.
  43558. */
  43559. static AddSamplers(samplers: string[]): void;
  43560. /**
  43561. * Makes a duplicate of the current configuration into another one.
  43562. * @param anisotropicConfiguration define the config where to copy the info
  43563. */
  43564. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43565. /**
  43566. * Serializes this anisotropy configuration.
  43567. * @returns - An object with the serialized config.
  43568. */
  43569. serialize(): any;
  43570. /**
  43571. * Parses a anisotropy Configuration from a serialized object.
  43572. * @param source - Serialized object.
  43573. */
  43574. parse(source: any): void;
  43575. }
  43576. }
  43577. declare module BABYLON {
  43578. /**
  43579. * @hidden
  43580. */
  43581. export interface IMaterialBRDFDefines {
  43582. BRDF_V_HEIGHT_CORRELATED: boolean;
  43583. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43584. /** @hidden */ areMiscDirty: boolean;
  43585. }
  43586. /**
  43587. * Define the code related to the BRDF parameters of the pbr material.
  43588. */
  43589. export class PBRBRDFConfiguration {
  43590. /**
  43591. * Default value used for the energy conservation.
  43592. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43593. */
  43594. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43595. /**
  43596. * Default value used for the Smith Visibility Height Correlated mode.
  43597. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43598. */
  43599. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43600. private _useEnergyConservation;
  43601. /**
  43602. * Defines if the material uses energy conservation.
  43603. */
  43604. useEnergyConservation: boolean;
  43605. private _useSmithVisibilityHeightCorrelated;
  43606. /**
  43607. * LEGACY Mode set to false
  43608. * Defines if the material uses height smith correlated visibility term.
  43609. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43610. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43611. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43612. * Not relying on height correlated will also disable energy conservation.
  43613. */
  43614. useSmithVisibilityHeightCorrelated: boolean;
  43615. /** @hidden */
  43616. private _internalMarkAllSubMeshesAsMiscDirty;
  43617. /** @hidden */ markAllSubMeshesAsMiscDirty(): void;
  43618. /**
  43619. * Instantiate a new istance of clear coat configuration.
  43620. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43621. */
  43622. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43623. /**
  43624. * Checks to see if a texture is used in the material.
  43625. * @param defines the list of "defines" to update.
  43626. */
  43627. prepareDefines(defines: IMaterialBRDFDefines): void;
  43628. /**
  43629. * Get the current class name of the texture useful for serialization or dynamic coding.
  43630. * @returns "PBRClearCoatConfiguration"
  43631. */
  43632. getClassName(): string;
  43633. /**
  43634. * Makes a duplicate of the current configuration into another one.
  43635. * @param brdfConfiguration define the config where to copy the info
  43636. */
  43637. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43638. /**
  43639. * Serializes this BRDF configuration.
  43640. * @returns - An object with the serialized config.
  43641. */
  43642. serialize(): any;
  43643. /**
  43644. * Parses a BRDF Configuration from a serialized object.
  43645. * @param source - Serialized object.
  43646. */
  43647. parse(source: any): void;
  43648. }
  43649. }
  43650. declare module BABYLON {
  43651. /**
  43652. * @hidden
  43653. */
  43654. export interface IMaterialSheenDefines {
  43655. SHEEN: boolean;
  43656. SHEEN_TEXTURE: boolean;
  43657. SHEEN_TEXTUREDIRECTUV: number;
  43658. SHEEN_LINKWITHALBEDO: boolean;
  43659. /** @hidden */ areTexturesDirty: boolean;
  43660. }
  43661. /**
  43662. * Define the code related to the Sheen parameters of the pbr material.
  43663. */
  43664. export class PBRSheenConfiguration {
  43665. private _isEnabled;
  43666. /**
  43667. * Defines if the material uses sheen.
  43668. */
  43669. isEnabled: boolean;
  43670. private _linkSheenWithAlbedo;
  43671. /**
  43672. * Defines if the sheen is linked to the sheen color.
  43673. */
  43674. linkSheenWithAlbedo: boolean;
  43675. /**
  43676. * Defines the sheen intensity.
  43677. */
  43678. intensity: number;
  43679. /**
  43680. * Defines the sheen color.
  43681. */
  43682. color: Color3;
  43683. private _texture;
  43684. /**
  43685. * Stores the sheen tint values in a texture.
  43686. * rgb is tint
  43687. * a is a intensity
  43688. */
  43689. texture: Nullable<BaseTexture>;
  43690. /** @hidden */
  43691. private _internalMarkAllSubMeshesAsTexturesDirty;
  43692. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43693. /**
  43694. * Instantiate a new istance of clear coat configuration.
  43695. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43696. */
  43697. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43698. /**
  43699. * Specifies that the submesh is ready to be used.
  43700. * @param defines the list of "defines" to update.
  43701. * @param scene defines the scene the material belongs to.
  43702. * @returns - boolean indicating that the submesh is ready or not.
  43703. */
  43704. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43705. /**
  43706. * Checks to see if a texture is used in the material.
  43707. * @param defines the list of "defines" to update.
  43708. * @param scene defines the scene the material belongs to.
  43709. */
  43710. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43711. /**
  43712. * Binds the material data.
  43713. * @param uniformBuffer defines the Uniform buffer to fill in.
  43714. * @param scene defines the scene the material belongs to.
  43715. * @param isFrozen defines wether the material is frozen or not.
  43716. */
  43717. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43718. /**
  43719. * Checks to see if a texture is used in the material.
  43720. * @param texture - Base texture to use.
  43721. * @returns - Boolean specifying if a texture is used in the material.
  43722. */
  43723. hasTexture(texture: BaseTexture): boolean;
  43724. /**
  43725. * Returns an array of the actively used textures.
  43726. * @param activeTextures Array of BaseTextures
  43727. */
  43728. getActiveTextures(activeTextures: BaseTexture[]): void;
  43729. /**
  43730. * Returns the animatable textures.
  43731. * @param animatables Array of animatable textures.
  43732. */
  43733. getAnimatables(animatables: IAnimatable[]): void;
  43734. /**
  43735. * Disposes the resources of the material.
  43736. * @param forceDisposeTextures - Forces the disposal of all textures.
  43737. */
  43738. dispose(forceDisposeTextures?: boolean): void;
  43739. /**
  43740. * Get the current class name of the texture useful for serialization or dynamic coding.
  43741. * @returns "PBRSheenConfiguration"
  43742. */
  43743. getClassName(): string;
  43744. /**
  43745. * Add fallbacks to the effect fallbacks list.
  43746. * @param defines defines the Base texture to use.
  43747. * @param fallbacks defines the current fallback list.
  43748. * @param currentRank defines the current fallback rank.
  43749. * @returns the new fallback rank.
  43750. */
  43751. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43752. /**
  43753. * Add the required uniforms to the current list.
  43754. * @param uniforms defines the current uniform list.
  43755. */
  43756. static AddUniforms(uniforms: string[]): void;
  43757. /**
  43758. * Add the required uniforms to the current buffer.
  43759. * @param uniformBuffer defines the current uniform buffer.
  43760. */
  43761. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43762. /**
  43763. * Add the required samplers to the current list.
  43764. * @param samplers defines the current sampler list.
  43765. */
  43766. static AddSamplers(samplers: string[]): void;
  43767. /**
  43768. * Makes a duplicate of the current configuration into another one.
  43769. * @param sheenConfiguration define the config where to copy the info
  43770. */
  43771. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43772. /**
  43773. * Serializes this BRDF configuration.
  43774. * @returns - An object with the serialized config.
  43775. */
  43776. serialize(): any;
  43777. /**
  43778. * Parses a Sheen Configuration from a serialized object.
  43779. * @param source - Serialized object.
  43780. */
  43781. parse(source: any): void;
  43782. }
  43783. }
  43784. declare module BABYLON {
  43785. /**
  43786. * @hidden
  43787. */
  43788. export interface IMaterialSubSurfaceDefines {
  43789. SUBSURFACE: boolean;
  43790. SS_REFRACTION: boolean;
  43791. SS_TRANSLUCENCY: boolean;
  43792. SS_SCATERRING: boolean;
  43793. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43794. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43795. SS_REFRACTIONMAP_3D: boolean;
  43796. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43797. SS_LODINREFRACTIONALPHA: boolean;
  43798. SS_GAMMAREFRACTION: boolean;
  43799. SS_RGBDREFRACTION: boolean;
  43800. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43801. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43802. /** @hidden */ areTexturesDirty: boolean;
  43803. }
  43804. /**
  43805. * Define the code related to the sub surface parameters of the pbr material.
  43806. */
  43807. export class PBRSubSurfaceConfiguration {
  43808. private _isRefractionEnabled;
  43809. /**
  43810. * Defines if the refraction is enabled in the material.
  43811. */
  43812. isRefractionEnabled: boolean;
  43813. private _isTranslucencyEnabled;
  43814. /**
  43815. * Defines if the translucency is enabled in the material.
  43816. */
  43817. isTranslucencyEnabled: boolean;
  43818. private _isScatteringEnabled;
  43819. /**
  43820. * Defines the refraction intensity of the material.
  43821. * The refraction when enabled replaces the Diffuse part of the material.
  43822. * The intensity helps transitionning between diffuse and refraction.
  43823. */
  43824. refractionIntensity: number;
  43825. /**
  43826. * Defines the translucency intensity of the material.
  43827. * When translucency has been enabled, this defines how much of the "translucency"
  43828. * is addded to the diffuse part of the material.
  43829. */
  43830. translucencyIntensity: number;
  43831. /**
  43832. * Defines the scattering intensity of the material.
  43833. * When scattering has been enabled, this defines how much of the "scattered light"
  43834. * is addded to the diffuse part of the material.
  43835. */
  43836. scatteringIntensity: number;
  43837. private _thicknessTexture;
  43838. /**
  43839. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  43840. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  43841. * 0 would mean minimumThickness
  43842. * 1 would mean maximumThickness
  43843. * The other channels might be use as a mask to vary the different effects intensity.
  43844. */
  43845. thicknessTexture: Nullable<BaseTexture>;
  43846. private _refractionTexture;
  43847. /**
  43848. * Defines the texture to use for refraction.
  43849. */
  43850. refractionTexture: Nullable<BaseTexture>;
  43851. private _indexOfRefraction;
  43852. /**
  43853. * Defines the indice of refraction used in the material.
  43854. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  43855. */
  43856. indexOfRefraction: number;
  43857. private _invertRefractionY;
  43858. /**
  43859. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43860. */
  43861. invertRefractionY: boolean;
  43862. private _linkRefractionWithTransparency;
  43863. /**
  43864. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43865. * Materials half opaque for instance using refraction could benefit from this control.
  43866. */
  43867. linkRefractionWithTransparency: boolean;
  43868. /**
  43869. * Defines the minimum thickness stored in the thickness map.
  43870. * If no thickness map is defined, this value will be used to simulate thickness.
  43871. */
  43872. minimumThickness: number;
  43873. /**
  43874. * Defines the maximum thickness stored in the thickness map.
  43875. */
  43876. maximumThickness: number;
  43877. /**
  43878. * Defines the volume tint of the material.
  43879. * This is used for both translucency and scattering.
  43880. */
  43881. tintColor: Color3;
  43882. /**
  43883. * Defines the distance at which the tint color should be found in the media.
  43884. * This is used for refraction only.
  43885. */
  43886. tintColorAtDistance: number;
  43887. /**
  43888. * Defines how far each channel transmit through the media.
  43889. * It is defined as a color to simplify it selection.
  43890. */
  43891. diffusionDistance: Color3;
  43892. private _useMaskFromThicknessTexture;
  43893. /**
  43894. * Stores the intensity of the different subsurface effects in the thickness texture.
  43895. * * the green channel is the translucency intensity.
  43896. * * the blue channel is the scattering intensity.
  43897. * * the alpha channel is the refraction intensity.
  43898. */
  43899. useMaskFromThicknessTexture: boolean;
  43900. /** @hidden */
  43901. private _internalMarkAllSubMeshesAsTexturesDirty;
  43902. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43903. /**
  43904. * Instantiate a new istance of sub surface configuration.
  43905. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43906. */
  43907. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43908. /**
  43909. * Gets wehter the submesh is ready to be used or not.
  43910. * @param defines the list of "defines" to update.
  43911. * @param scene defines the scene the material belongs to.
  43912. * @returns - boolean indicating that the submesh is ready or not.
  43913. */
  43914. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  43915. /**
  43916. * Checks to see if a texture is used in the material.
  43917. * @param defines the list of "defines" to update.
  43918. * @param scene defines the scene to the material belongs to.
  43919. */
  43920. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  43921. /**
  43922. * Binds the material data.
  43923. * @param uniformBuffer defines the Uniform buffer to fill in.
  43924. * @param scene defines the scene the material belongs to.
  43925. * @param engine defines the engine the material belongs to.
  43926. * @param isFrozen defines wether the material is frozen or not.
  43927. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  43928. */
  43929. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  43930. /**
  43931. * Unbinds the material from the mesh.
  43932. * @param activeEffect defines the effect that should be unbound from.
  43933. * @returns true if unbound, otherwise false
  43934. */
  43935. unbind(activeEffect: Effect): boolean;
  43936. /**
  43937. * Returns the texture used for refraction or null if none is used.
  43938. * @param scene defines the scene the material belongs to.
  43939. * @returns - Refraction texture if present. If no refraction texture and refraction
  43940. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43941. */
  43942. private _getRefractionTexture;
  43943. /**
  43944. * Returns true if alpha blending should be disabled.
  43945. */
  43946. readonly disableAlphaBlending: boolean;
  43947. /**
  43948. * Fills the list of render target textures.
  43949. * @param renderTargets the list of render targets to update
  43950. */
  43951. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  43952. /**
  43953. * Checks to see if a texture is used in the material.
  43954. * @param texture - Base texture to use.
  43955. * @returns - Boolean specifying if a texture is used in the material.
  43956. */
  43957. hasTexture(texture: BaseTexture): boolean;
  43958. /**
  43959. * Gets a boolean indicating that current material needs to register RTT
  43960. * @returns true if this uses a render target otherwise false.
  43961. */
  43962. hasRenderTargetTextures(): boolean;
  43963. /**
  43964. * Returns an array of the actively used textures.
  43965. * @param activeTextures Array of BaseTextures
  43966. */
  43967. getActiveTextures(activeTextures: BaseTexture[]): void;
  43968. /**
  43969. * Returns the animatable textures.
  43970. * @param animatables Array of animatable textures.
  43971. */
  43972. getAnimatables(animatables: IAnimatable[]): void;
  43973. /**
  43974. * Disposes the resources of the material.
  43975. * @param forceDisposeTextures - Forces the disposal of all textures.
  43976. */
  43977. dispose(forceDisposeTextures?: boolean): void;
  43978. /**
  43979. * Get the current class name of the texture useful for serialization or dynamic coding.
  43980. * @returns "PBRSubSurfaceConfiguration"
  43981. */
  43982. getClassName(): string;
  43983. /**
  43984. * Add fallbacks to the effect fallbacks list.
  43985. * @param defines defines the Base texture to use.
  43986. * @param fallbacks defines the current fallback list.
  43987. * @param currentRank defines the current fallback rank.
  43988. * @returns the new fallback rank.
  43989. */
  43990. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43991. /**
  43992. * Add the required uniforms to the current list.
  43993. * @param uniforms defines the current uniform list.
  43994. */
  43995. static AddUniforms(uniforms: string[]): void;
  43996. /**
  43997. * Add the required samplers to the current list.
  43998. * @param samplers defines the current sampler list.
  43999. */
  44000. static AddSamplers(samplers: string[]): void;
  44001. /**
  44002. * Add the required uniforms to the current buffer.
  44003. * @param uniformBuffer defines the current uniform buffer.
  44004. */
  44005. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44006. /**
  44007. * Makes a duplicate of the current configuration into another one.
  44008. * @param configuration define the config where to copy the info
  44009. */
  44010. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44011. /**
  44012. * Serializes this Sub Surface configuration.
  44013. * @returns - An object with the serialized config.
  44014. */
  44015. serialize(): any;
  44016. /**
  44017. * Parses a Sub Surface Configuration from a serialized object.
  44018. * @param source - Serialized object.
  44019. */
  44020. parse(source: any): void;
  44021. }
  44022. }
  44023. declare module BABYLON {
  44024. /** @hidden */
  44025. export var pbrFragmentDeclaration: {
  44026. name: string;
  44027. shader: string;
  44028. };
  44029. }
  44030. declare module BABYLON {
  44031. /** @hidden */
  44032. export var pbrUboDeclaration: {
  44033. name: string;
  44034. shader: string;
  44035. };
  44036. }
  44037. declare module BABYLON {
  44038. /** @hidden */
  44039. export var pbrFragmentExtraDeclaration: {
  44040. name: string;
  44041. shader: string;
  44042. };
  44043. }
  44044. declare module BABYLON {
  44045. /** @hidden */
  44046. export var pbrFragmentSamplersDeclaration: {
  44047. name: string;
  44048. shader: string;
  44049. };
  44050. }
  44051. declare module BABYLON {
  44052. /** @hidden */
  44053. export var pbrHelperFunctions: {
  44054. name: string;
  44055. shader: string;
  44056. };
  44057. }
  44058. declare module BABYLON {
  44059. /** @hidden */
  44060. export var harmonicsFunctions: {
  44061. name: string;
  44062. shader: string;
  44063. };
  44064. }
  44065. declare module BABYLON {
  44066. /** @hidden */
  44067. export var pbrDirectLightingSetupFunctions: {
  44068. name: string;
  44069. shader: string;
  44070. };
  44071. }
  44072. declare module BABYLON {
  44073. /** @hidden */
  44074. export var pbrDirectLightingFalloffFunctions: {
  44075. name: string;
  44076. shader: string;
  44077. };
  44078. }
  44079. declare module BABYLON {
  44080. /** @hidden */
  44081. export var pbrBRDFFunctions: {
  44082. name: string;
  44083. shader: string;
  44084. };
  44085. }
  44086. declare module BABYLON {
  44087. /** @hidden */
  44088. export var pbrDirectLightingFunctions: {
  44089. name: string;
  44090. shader: string;
  44091. };
  44092. }
  44093. declare module BABYLON {
  44094. /** @hidden */
  44095. export var pbrIBLFunctions: {
  44096. name: string;
  44097. shader: string;
  44098. };
  44099. }
  44100. declare module BABYLON {
  44101. /** @hidden */
  44102. export var pbrDebug: {
  44103. name: string;
  44104. shader: string;
  44105. };
  44106. }
  44107. declare module BABYLON {
  44108. /** @hidden */
  44109. export var pbrPixelShader: {
  44110. name: string;
  44111. shader: string;
  44112. };
  44113. }
  44114. declare module BABYLON {
  44115. /** @hidden */
  44116. export var pbrVertexDeclaration: {
  44117. name: string;
  44118. shader: string;
  44119. };
  44120. }
  44121. declare module BABYLON {
  44122. /** @hidden */
  44123. export var pbrVertexShader: {
  44124. name: string;
  44125. shader: string;
  44126. };
  44127. }
  44128. declare module BABYLON {
  44129. /**
  44130. * Manages the defines for the PBR Material.
  44131. * @hidden
  44132. */
  44133. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44134. PBR: boolean;
  44135. MAINUV1: boolean;
  44136. MAINUV2: boolean;
  44137. UV1: boolean;
  44138. UV2: boolean;
  44139. ALBEDO: boolean;
  44140. ALBEDODIRECTUV: number;
  44141. VERTEXCOLOR: boolean;
  44142. AMBIENT: boolean;
  44143. AMBIENTDIRECTUV: number;
  44144. AMBIENTINGRAYSCALE: boolean;
  44145. OPACITY: boolean;
  44146. VERTEXALPHA: boolean;
  44147. OPACITYDIRECTUV: number;
  44148. OPACITYRGB: boolean;
  44149. ALPHATEST: boolean;
  44150. DEPTHPREPASS: boolean;
  44151. ALPHABLEND: boolean;
  44152. ALPHAFROMALBEDO: boolean;
  44153. ALPHATESTVALUE: string;
  44154. SPECULAROVERALPHA: boolean;
  44155. RADIANCEOVERALPHA: boolean;
  44156. ALPHAFRESNEL: boolean;
  44157. LINEARALPHAFRESNEL: boolean;
  44158. PREMULTIPLYALPHA: boolean;
  44159. EMISSIVE: boolean;
  44160. EMISSIVEDIRECTUV: number;
  44161. REFLECTIVITY: boolean;
  44162. REFLECTIVITYDIRECTUV: number;
  44163. SPECULARTERM: boolean;
  44164. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44165. MICROSURFACEAUTOMATIC: boolean;
  44166. LODBASEDMICROSFURACE: boolean;
  44167. MICROSURFACEMAP: boolean;
  44168. MICROSURFACEMAPDIRECTUV: number;
  44169. METALLICWORKFLOW: boolean;
  44170. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44171. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44172. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44173. AOSTOREINMETALMAPRED: boolean;
  44174. ENVIRONMENTBRDF: boolean;
  44175. ENVIRONMENTBRDF_RGBD: boolean;
  44176. NORMAL: boolean;
  44177. TANGENT: boolean;
  44178. BUMP: boolean;
  44179. BUMPDIRECTUV: number;
  44180. OBJECTSPACE_NORMALMAP: boolean;
  44181. PARALLAX: boolean;
  44182. PARALLAXOCCLUSION: boolean;
  44183. NORMALXYSCALE: boolean;
  44184. LIGHTMAP: boolean;
  44185. LIGHTMAPDIRECTUV: number;
  44186. USELIGHTMAPASSHADOWMAP: boolean;
  44187. GAMMALIGHTMAP: boolean;
  44188. REFLECTION: boolean;
  44189. REFLECTIONMAP_3D: boolean;
  44190. REFLECTIONMAP_SPHERICAL: boolean;
  44191. REFLECTIONMAP_PLANAR: boolean;
  44192. REFLECTIONMAP_CUBIC: boolean;
  44193. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44194. REFLECTIONMAP_PROJECTION: boolean;
  44195. REFLECTIONMAP_SKYBOX: boolean;
  44196. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44197. REFLECTIONMAP_EXPLICIT: boolean;
  44198. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44199. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44200. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44201. INVERTCUBICMAP: boolean;
  44202. USESPHERICALFROMREFLECTIONMAP: boolean;
  44203. USESPHERICALINVERTEX: boolean;
  44204. REFLECTIONMAP_OPPOSITEZ: boolean;
  44205. LODINREFLECTIONALPHA: boolean;
  44206. GAMMAREFLECTION: boolean;
  44207. RGBDREFLECTION: boolean;
  44208. RADIANCEOCCLUSION: boolean;
  44209. HORIZONOCCLUSION: boolean;
  44210. INSTANCES: boolean;
  44211. NUM_BONE_INFLUENCERS: number;
  44212. BonesPerMesh: number;
  44213. BONETEXTURE: boolean;
  44214. NONUNIFORMSCALING: boolean;
  44215. MORPHTARGETS: boolean;
  44216. MORPHTARGETS_NORMAL: boolean;
  44217. MORPHTARGETS_TANGENT: boolean;
  44218. NUM_MORPH_INFLUENCERS: number;
  44219. IMAGEPROCESSING: boolean;
  44220. VIGNETTE: boolean;
  44221. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44222. VIGNETTEBLENDMODEOPAQUE: boolean;
  44223. TONEMAPPING: boolean;
  44224. TONEMAPPING_ACES: boolean;
  44225. CONTRAST: boolean;
  44226. COLORCURVES: boolean;
  44227. COLORGRADING: boolean;
  44228. COLORGRADING3D: boolean;
  44229. SAMPLER3DGREENDEPTH: boolean;
  44230. SAMPLER3DBGRMAP: boolean;
  44231. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44232. EXPOSURE: boolean;
  44233. MULTIVIEW: boolean;
  44234. USEPHYSICALLIGHTFALLOFF: boolean;
  44235. USEGLTFLIGHTFALLOFF: boolean;
  44236. TWOSIDEDLIGHTING: boolean;
  44237. SHADOWFLOAT: boolean;
  44238. CLIPPLANE: boolean;
  44239. CLIPPLANE2: boolean;
  44240. CLIPPLANE3: boolean;
  44241. CLIPPLANE4: boolean;
  44242. POINTSIZE: boolean;
  44243. FOG: boolean;
  44244. LOGARITHMICDEPTH: boolean;
  44245. FORCENORMALFORWARD: boolean;
  44246. SPECULARAA: boolean;
  44247. CLEARCOAT: boolean;
  44248. CLEARCOAT_DEFAULTIOR: boolean;
  44249. CLEARCOAT_TEXTURE: boolean;
  44250. CLEARCOAT_TEXTUREDIRECTUV: number;
  44251. CLEARCOAT_BUMP: boolean;
  44252. CLEARCOAT_BUMPDIRECTUV: number;
  44253. CLEARCOAT_TINT: boolean;
  44254. CLEARCOAT_TINT_TEXTURE: boolean;
  44255. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44256. ANISOTROPIC: boolean;
  44257. ANISOTROPIC_TEXTURE: boolean;
  44258. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44259. BRDF_V_HEIGHT_CORRELATED: boolean;
  44260. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44261. SHEEN: boolean;
  44262. SHEEN_TEXTURE: boolean;
  44263. SHEEN_TEXTUREDIRECTUV: number;
  44264. SHEEN_LINKWITHALBEDO: boolean;
  44265. SUBSURFACE: boolean;
  44266. SS_REFRACTION: boolean;
  44267. SS_TRANSLUCENCY: boolean;
  44268. SS_SCATERRING: boolean;
  44269. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44270. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44271. SS_REFRACTIONMAP_3D: boolean;
  44272. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44273. SS_LODINREFRACTIONALPHA: boolean;
  44274. SS_GAMMAREFRACTION: boolean;
  44275. SS_RGBDREFRACTION: boolean;
  44276. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44277. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44278. UNLIT: boolean;
  44279. DEBUGMODE: number;
  44280. /**
  44281. * Initializes the PBR Material defines.
  44282. */
  44283. constructor();
  44284. /**
  44285. * Resets the PBR Material defines.
  44286. */
  44287. reset(): void;
  44288. }
  44289. /**
  44290. * The Physically based material base class of BJS.
  44291. *
  44292. * This offers the main features of a standard PBR material.
  44293. * For more information, please refer to the documentation :
  44294. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44295. */
  44296. export abstract class PBRBaseMaterial extends PushMaterial {
  44297. /**
  44298. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44299. */
  44300. static readonly PBRMATERIAL_OPAQUE: number;
  44301. /**
  44302. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44303. */
  44304. static readonly PBRMATERIAL_ALPHATEST: number;
  44305. /**
  44306. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44307. */
  44308. static readonly PBRMATERIAL_ALPHABLEND: number;
  44309. /**
  44310. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44311. * They are also discarded below the alpha cutoff threshold to improve performances.
  44312. */
  44313. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44314. /**
  44315. * Defines the default value of how much AO map is occluding the analytical lights
  44316. * (point spot...).
  44317. */
  44318. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44319. /**
  44320. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44321. */
  44322. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44323. /**
  44324. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44325. * to enhance interoperability with other engines.
  44326. */
  44327. static readonly LIGHTFALLOFF_GLTF: number;
  44328. /**
  44329. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44330. * to enhance interoperability with other materials.
  44331. */
  44332. static readonly LIGHTFALLOFF_STANDARD: number;
  44333. /**
  44334. * Intensity of the direct lights e.g. the four lights available in your scene.
  44335. * This impacts both the direct diffuse and specular highlights.
  44336. */
  44337. protected _directIntensity: number;
  44338. /**
  44339. * Intensity of the emissive part of the material.
  44340. * This helps controlling the emissive effect without modifying the emissive color.
  44341. */
  44342. protected _emissiveIntensity: number;
  44343. /**
  44344. * Intensity of the environment e.g. how much the environment will light the object
  44345. * either through harmonics for rough material or through the refelction for shiny ones.
  44346. */
  44347. protected _environmentIntensity: number;
  44348. /**
  44349. * This is a special control allowing the reduction of the specular highlights coming from the
  44350. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44351. */
  44352. protected _specularIntensity: number;
  44353. /**
  44354. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44355. */
  44356. private _lightingInfos;
  44357. /**
  44358. * Debug Control allowing disabling the bump map on this material.
  44359. */
  44360. protected _disableBumpMap: boolean;
  44361. /**
  44362. * AKA Diffuse Texture in standard nomenclature.
  44363. */
  44364. protected _albedoTexture: Nullable<BaseTexture>;
  44365. /**
  44366. * AKA Occlusion Texture in other nomenclature.
  44367. */
  44368. protected _ambientTexture: Nullable<BaseTexture>;
  44369. /**
  44370. * AKA Occlusion Texture Intensity in other nomenclature.
  44371. */
  44372. protected _ambientTextureStrength: number;
  44373. /**
  44374. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44375. * 1 means it completely occludes it
  44376. * 0 mean it has no impact
  44377. */
  44378. protected _ambientTextureImpactOnAnalyticalLights: number;
  44379. /**
  44380. * Stores the alpha values in a texture.
  44381. */
  44382. protected _opacityTexture: Nullable<BaseTexture>;
  44383. /**
  44384. * Stores the reflection values in a texture.
  44385. */
  44386. protected _reflectionTexture: Nullable<BaseTexture>;
  44387. /**
  44388. * Stores the emissive values in a texture.
  44389. */
  44390. protected _emissiveTexture: Nullable<BaseTexture>;
  44391. /**
  44392. * AKA Specular texture in other nomenclature.
  44393. */
  44394. protected _reflectivityTexture: Nullable<BaseTexture>;
  44395. /**
  44396. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44397. */
  44398. protected _metallicTexture: Nullable<BaseTexture>;
  44399. /**
  44400. * Specifies the metallic scalar of the metallic/roughness workflow.
  44401. * Can also be used to scale the metalness values of the metallic texture.
  44402. */
  44403. protected _metallic: Nullable<number>;
  44404. /**
  44405. * Specifies the roughness scalar of the metallic/roughness workflow.
  44406. * Can also be used to scale the roughness values of the metallic texture.
  44407. */
  44408. protected _roughness: Nullable<number>;
  44409. /**
  44410. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44411. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44412. */
  44413. protected _microSurfaceTexture: Nullable<BaseTexture>;
  44414. /**
  44415. * Stores surface normal data used to displace a mesh in a texture.
  44416. */
  44417. protected _bumpTexture: Nullable<BaseTexture>;
  44418. /**
  44419. * Stores the pre-calculated light information of a mesh in a texture.
  44420. */
  44421. protected _lightmapTexture: Nullable<BaseTexture>;
  44422. /**
  44423. * The color of a material in ambient lighting.
  44424. */
  44425. protected _ambientColor: Color3;
  44426. /**
  44427. * AKA Diffuse Color in other nomenclature.
  44428. */
  44429. protected _albedoColor: Color3;
  44430. /**
  44431. * AKA Specular Color in other nomenclature.
  44432. */
  44433. protected _reflectivityColor: Color3;
  44434. /**
  44435. * The color applied when light is reflected from a material.
  44436. */
  44437. protected _reflectionColor: Color3;
  44438. /**
  44439. * The color applied when light is emitted from a material.
  44440. */
  44441. protected _emissiveColor: Color3;
  44442. /**
  44443. * AKA Glossiness in other nomenclature.
  44444. */
  44445. protected _microSurface: number;
  44446. /**
  44447. * Specifies that the material will use the light map as a show map.
  44448. */
  44449. protected _useLightmapAsShadowmap: boolean;
  44450. /**
  44451. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44452. * makes the reflect vector face the model (under horizon).
  44453. */
  44454. protected _useHorizonOcclusion: boolean;
  44455. /**
  44456. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44457. * too much the area relying on ambient texture to define their ambient occlusion.
  44458. */
  44459. protected _useRadianceOcclusion: boolean;
  44460. /**
  44461. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44462. */
  44463. protected _useAlphaFromAlbedoTexture: boolean;
  44464. /**
  44465. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44466. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44467. */
  44468. protected _useSpecularOverAlpha: boolean;
  44469. /**
  44470. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44471. */
  44472. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44473. /**
  44474. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44475. */
  44476. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44477. /**
  44478. * Specifies if the metallic texture contains the roughness information in its green channel.
  44479. */
  44480. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44481. /**
  44482. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44483. */
  44484. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44485. /**
  44486. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44487. */
  44488. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44489. /**
  44490. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44491. */
  44492. protected _useAmbientInGrayScale: boolean;
  44493. /**
  44494. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44495. * The material will try to infer what glossiness each pixel should be.
  44496. */
  44497. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44498. /**
  44499. * Defines the falloff type used in this material.
  44500. * It by default is Physical.
  44501. */
  44502. protected _lightFalloff: number;
  44503. /**
  44504. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44505. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44506. */
  44507. protected _useRadianceOverAlpha: boolean;
  44508. /**
  44509. * Allows using an object space normal map (instead of tangent space).
  44510. */
  44511. protected _useObjectSpaceNormalMap: boolean;
  44512. /**
  44513. * Allows using the bump map in parallax mode.
  44514. */
  44515. protected _useParallax: boolean;
  44516. /**
  44517. * Allows using the bump map in parallax occlusion mode.
  44518. */
  44519. protected _useParallaxOcclusion: boolean;
  44520. /**
  44521. * Controls the scale bias of the parallax mode.
  44522. */
  44523. protected _parallaxScaleBias: number;
  44524. /**
  44525. * If sets to true, disables all the lights affecting the material.
  44526. */
  44527. protected _disableLighting: boolean;
  44528. /**
  44529. * Number of Simultaneous lights allowed on the material.
  44530. */
  44531. protected _maxSimultaneousLights: number;
  44532. /**
  44533. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44534. */
  44535. protected _invertNormalMapX: boolean;
  44536. /**
  44537. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44538. */
  44539. protected _invertNormalMapY: boolean;
  44540. /**
  44541. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44542. */
  44543. protected _twoSidedLighting: boolean;
  44544. /**
  44545. * Defines the alpha limits in alpha test mode.
  44546. */
  44547. protected _alphaCutOff: number;
  44548. /**
  44549. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44550. */
  44551. protected _forceAlphaTest: boolean;
  44552. /**
  44553. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44554. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44555. */
  44556. protected _useAlphaFresnel: boolean;
  44557. /**
  44558. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44559. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44560. */
  44561. protected _useLinearAlphaFresnel: boolean;
  44562. /**
  44563. * The transparency mode of the material.
  44564. */
  44565. protected _transparencyMode: Nullable<number>;
  44566. /**
  44567. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44568. * from cos thetav and roughness:
  44569. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44570. */
  44571. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44572. /**
  44573. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44574. */
  44575. protected _forceIrradianceInFragment: boolean;
  44576. /**
  44577. * Force normal to face away from face.
  44578. */
  44579. protected _forceNormalForward: boolean;
  44580. /**
  44581. * Enables specular anti aliasing in the PBR shader.
  44582. * It will both interacts on the Geometry for analytical and IBL lighting.
  44583. * It also prefilter the roughness map based on the bump values.
  44584. */
  44585. protected _enableSpecularAntiAliasing: boolean;
  44586. /**
  44587. * Default configuration related to image processing available in the PBR Material.
  44588. */
  44589. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44590. /**
  44591. * Keep track of the image processing observer to allow dispose and replace.
  44592. */
  44593. private _imageProcessingObserver;
  44594. /**
  44595. * Attaches a new image processing configuration to the PBR Material.
  44596. * @param configuration
  44597. */
  44598. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44599. /**
  44600. * Stores the available render targets.
  44601. */
  44602. private _renderTargets;
  44603. /**
  44604. * Sets the global ambient color for the material used in lighting calculations.
  44605. */
  44606. private _globalAmbientColor;
  44607. /**
  44608. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44609. */
  44610. private _useLogarithmicDepth;
  44611. /**
  44612. * If set to true, no lighting calculations will be applied.
  44613. */
  44614. private _unlit;
  44615. private _debugMode;
  44616. /**
  44617. * @hidden
  44618. * This is reserved for the inspector.
  44619. * Defines the material debug mode.
  44620. * It helps seeing only some components of the material while troubleshooting.
  44621. */
  44622. debugMode: number;
  44623. /**
  44624. * @hidden
  44625. * This is reserved for the inspector.
  44626. * Specify from where on screen the debug mode should start.
  44627. * The value goes from -1 (full screen) to 1 (not visible)
  44628. * It helps with side by side comparison against the final render
  44629. * This defaults to -1
  44630. */
  44631. private debugLimit;
  44632. /**
  44633. * @hidden
  44634. * This is reserved for the inspector.
  44635. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44636. * You can use the factor to better multiply the final value.
  44637. */
  44638. private debugFactor;
  44639. /**
  44640. * Defines the clear coat layer parameters for the material.
  44641. */
  44642. readonly clearCoat: PBRClearCoatConfiguration;
  44643. /**
  44644. * Defines the anisotropic parameters for the material.
  44645. */
  44646. readonly anisotropy: PBRAnisotropicConfiguration;
  44647. /**
  44648. * Defines the BRDF parameters for the material.
  44649. */
  44650. readonly brdf: PBRBRDFConfiguration;
  44651. /**
  44652. * Defines the Sheen parameters for the material.
  44653. */
  44654. readonly sheen: PBRSheenConfiguration;
  44655. /**
  44656. * Defines the SubSurface parameters for the material.
  44657. */
  44658. readonly subSurface: PBRSubSurfaceConfiguration;
  44659. /**
  44660. * Custom callback helping to override the default shader used in the material.
  44661. */
  44662. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44663. /**
  44664. * Instantiates a new PBRMaterial instance.
  44665. *
  44666. * @param name The material name
  44667. * @param scene The scene the material will be use in.
  44668. */
  44669. constructor(name: string, scene: Scene);
  44670. /**
  44671. * Gets a boolean indicating that current material needs to register RTT
  44672. */
  44673. readonly hasRenderTargetTextures: boolean;
  44674. /**
  44675. * Gets the name of the material class.
  44676. */
  44677. getClassName(): string;
  44678. /**
  44679. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44680. */
  44681. /**
  44682. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44683. */
  44684. useLogarithmicDepth: boolean;
  44685. /**
  44686. * Gets the current transparency mode.
  44687. */
  44688. /**
  44689. * Sets the transparency mode of the material.
  44690. *
  44691. * | Value | Type | Description |
  44692. * | ----- | ----------------------------------- | ----------- |
  44693. * | 0 | OPAQUE | |
  44694. * | 1 | ALPHATEST | |
  44695. * | 2 | ALPHABLEND | |
  44696. * | 3 | ALPHATESTANDBLEND | |
  44697. *
  44698. */
  44699. transparencyMode: Nullable<number>;
  44700. /**
  44701. * Returns true if alpha blending should be disabled.
  44702. */
  44703. private readonly _disableAlphaBlending;
  44704. /**
  44705. * Specifies whether or not this material should be rendered in alpha blend mode.
  44706. */
  44707. needAlphaBlending(): boolean;
  44708. /**
  44709. * Specifies if the mesh will require alpha blending.
  44710. * @param mesh - BJS mesh.
  44711. */
  44712. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44713. /**
  44714. * Specifies whether or not this material should be rendered in alpha test mode.
  44715. */
  44716. needAlphaTesting(): boolean;
  44717. /**
  44718. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44719. */
  44720. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44721. /**
  44722. * Gets the texture used for the alpha test.
  44723. */
  44724. getAlphaTestTexture(): Nullable<BaseTexture>;
  44725. /**
  44726. * Specifies that the submesh is ready to be used.
  44727. * @param mesh - BJS mesh.
  44728. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44729. * @param useInstances - Specifies that instances should be used.
  44730. * @returns - boolean indicating that the submesh is ready or not.
  44731. */
  44732. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44733. /**
  44734. * Specifies if the material uses metallic roughness workflow.
  44735. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44736. */
  44737. isMetallicWorkflow(): boolean;
  44738. private _prepareEffect;
  44739. private _prepareDefines;
  44740. /**
  44741. * Force shader compilation
  44742. */
  44743. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44744. clipPlane: boolean;
  44745. }>): void;
  44746. /**
  44747. * Initializes the uniform buffer layout for the shader.
  44748. */
  44749. buildUniformLayout(): void;
  44750. /**
  44751. * Unbinds the material from the mesh
  44752. */
  44753. unbind(): void;
  44754. /**
  44755. * Binds the submesh data.
  44756. * @param world - The world matrix.
  44757. * @param mesh - The BJS mesh.
  44758. * @param subMesh - A submesh of the BJS mesh.
  44759. */
  44760. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44761. /**
  44762. * Returns the animatable textures.
  44763. * @returns - Array of animatable textures.
  44764. */
  44765. getAnimatables(): IAnimatable[];
  44766. /**
  44767. * Returns the texture used for reflections.
  44768. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44769. */
  44770. private _getReflectionTexture;
  44771. /**
  44772. * Returns an array of the actively used textures.
  44773. * @returns - Array of BaseTextures
  44774. */
  44775. getActiveTextures(): BaseTexture[];
  44776. /**
  44777. * Checks to see if a texture is used in the material.
  44778. * @param texture - Base texture to use.
  44779. * @returns - Boolean specifying if a texture is used in the material.
  44780. */
  44781. hasTexture(texture: BaseTexture): boolean;
  44782. /**
  44783. * Disposes the resources of the material.
  44784. * @param forceDisposeEffect - Forces the disposal of effects.
  44785. * @param forceDisposeTextures - Forces the disposal of all textures.
  44786. */
  44787. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44788. }
  44789. }
  44790. declare module BABYLON {
  44791. /**
  44792. * The Physically based material of BJS.
  44793. *
  44794. * This offers the main features of a standard PBR material.
  44795. * For more information, please refer to the documentation :
  44796. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44797. */
  44798. export class PBRMaterial extends PBRBaseMaterial {
  44799. /**
  44800. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44801. */
  44802. static readonly PBRMATERIAL_OPAQUE: number;
  44803. /**
  44804. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44805. */
  44806. static readonly PBRMATERIAL_ALPHATEST: number;
  44807. /**
  44808. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44809. */
  44810. static readonly PBRMATERIAL_ALPHABLEND: number;
  44811. /**
  44812. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44813. * They are also discarded below the alpha cutoff threshold to improve performances.
  44814. */
  44815. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44816. /**
  44817. * Defines the default value of how much AO map is occluding the analytical lights
  44818. * (point spot...).
  44819. */
  44820. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44821. /**
  44822. * Intensity of the direct lights e.g. the four lights available in your scene.
  44823. * This impacts both the direct diffuse and specular highlights.
  44824. */
  44825. directIntensity: number;
  44826. /**
  44827. * Intensity of the emissive part of the material.
  44828. * This helps controlling the emissive effect without modifying the emissive color.
  44829. */
  44830. emissiveIntensity: number;
  44831. /**
  44832. * Intensity of the environment e.g. how much the environment will light the object
  44833. * either through harmonics for rough material or through the refelction for shiny ones.
  44834. */
  44835. environmentIntensity: number;
  44836. /**
  44837. * This is a special control allowing the reduction of the specular highlights coming from the
  44838. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44839. */
  44840. specularIntensity: number;
  44841. /**
  44842. * Debug Control allowing disabling the bump map on this material.
  44843. */
  44844. disableBumpMap: boolean;
  44845. /**
  44846. * AKA Diffuse Texture in standard nomenclature.
  44847. */
  44848. albedoTexture: BaseTexture;
  44849. /**
  44850. * AKA Occlusion Texture in other nomenclature.
  44851. */
  44852. ambientTexture: BaseTexture;
  44853. /**
  44854. * AKA Occlusion Texture Intensity in other nomenclature.
  44855. */
  44856. ambientTextureStrength: number;
  44857. /**
  44858. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44859. * 1 means it completely occludes it
  44860. * 0 mean it has no impact
  44861. */
  44862. ambientTextureImpactOnAnalyticalLights: number;
  44863. /**
  44864. * Stores the alpha values in a texture.
  44865. */
  44866. opacityTexture: BaseTexture;
  44867. /**
  44868. * Stores the reflection values in a texture.
  44869. */
  44870. reflectionTexture: Nullable<BaseTexture>;
  44871. /**
  44872. * Stores the emissive values in a texture.
  44873. */
  44874. emissiveTexture: BaseTexture;
  44875. /**
  44876. * AKA Specular texture in other nomenclature.
  44877. */
  44878. reflectivityTexture: BaseTexture;
  44879. /**
  44880. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44881. */
  44882. metallicTexture: BaseTexture;
  44883. /**
  44884. * Specifies the metallic scalar of the metallic/roughness workflow.
  44885. * Can also be used to scale the metalness values of the metallic texture.
  44886. */
  44887. metallic: Nullable<number>;
  44888. /**
  44889. * Specifies the roughness scalar of the metallic/roughness workflow.
  44890. * Can also be used to scale the roughness values of the metallic texture.
  44891. */
  44892. roughness: Nullable<number>;
  44893. /**
  44894. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44895. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44896. */
  44897. microSurfaceTexture: BaseTexture;
  44898. /**
  44899. * Stores surface normal data used to displace a mesh in a texture.
  44900. */
  44901. bumpTexture: BaseTexture;
  44902. /**
  44903. * Stores the pre-calculated light information of a mesh in a texture.
  44904. */
  44905. lightmapTexture: BaseTexture;
  44906. /**
  44907. * Stores the refracted light information in a texture.
  44908. */
  44909. refractionTexture: Nullable<BaseTexture>;
  44910. /**
  44911. * The color of a material in ambient lighting.
  44912. */
  44913. ambientColor: Color3;
  44914. /**
  44915. * AKA Diffuse Color in other nomenclature.
  44916. */
  44917. albedoColor: Color3;
  44918. /**
  44919. * AKA Specular Color in other nomenclature.
  44920. */
  44921. reflectivityColor: Color3;
  44922. /**
  44923. * The color reflected from the material.
  44924. */
  44925. reflectionColor: Color3;
  44926. /**
  44927. * The color emitted from the material.
  44928. */
  44929. emissiveColor: Color3;
  44930. /**
  44931. * AKA Glossiness in other nomenclature.
  44932. */
  44933. microSurface: number;
  44934. /**
  44935. * source material index of refraction (IOR)' / 'destination material IOR.
  44936. */
  44937. indexOfRefraction: number;
  44938. /**
  44939. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44940. */
  44941. invertRefractionY: boolean;
  44942. /**
  44943. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44944. * Materials half opaque for instance using refraction could benefit from this control.
  44945. */
  44946. linkRefractionWithTransparency: boolean;
  44947. /**
  44948. * If true, the light map contains occlusion information instead of lighting info.
  44949. */
  44950. useLightmapAsShadowmap: boolean;
  44951. /**
  44952. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44953. */
  44954. useAlphaFromAlbedoTexture: boolean;
  44955. /**
  44956. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44957. */
  44958. forceAlphaTest: boolean;
  44959. /**
  44960. * Defines the alpha limits in alpha test mode.
  44961. */
  44962. alphaCutOff: number;
  44963. /**
  44964. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44965. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44966. */
  44967. useSpecularOverAlpha: boolean;
  44968. /**
  44969. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44970. */
  44971. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44972. /**
  44973. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44974. */
  44975. useRoughnessFromMetallicTextureAlpha: boolean;
  44976. /**
  44977. * Specifies if the metallic texture contains the roughness information in its green channel.
  44978. */
  44979. useRoughnessFromMetallicTextureGreen: boolean;
  44980. /**
  44981. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44982. */
  44983. useMetallnessFromMetallicTextureBlue: boolean;
  44984. /**
  44985. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44986. */
  44987. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44988. /**
  44989. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44990. */
  44991. useAmbientInGrayScale: boolean;
  44992. /**
  44993. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44994. * The material will try to infer what glossiness each pixel should be.
  44995. */
  44996. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44997. /**
  44998. * BJS is using an harcoded light falloff based on a manually sets up range.
  44999. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45000. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45001. */
  45002. /**
  45003. * BJS is using an harcoded light falloff based on a manually sets up range.
  45004. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45005. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45006. */
  45007. usePhysicalLightFalloff: boolean;
  45008. /**
  45009. * In order to support the falloff compatibility with gltf, a special mode has been added
  45010. * to reproduce the gltf light falloff.
  45011. */
  45012. /**
  45013. * In order to support the falloff compatibility with gltf, a special mode has been added
  45014. * to reproduce the gltf light falloff.
  45015. */
  45016. useGLTFLightFalloff: boolean;
  45017. /**
  45018. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45019. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45020. */
  45021. useRadianceOverAlpha: boolean;
  45022. /**
  45023. * Allows using an object space normal map (instead of tangent space).
  45024. */
  45025. useObjectSpaceNormalMap: boolean;
  45026. /**
  45027. * Allows using the bump map in parallax mode.
  45028. */
  45029. useParallax: boolean;
  45030. /**
  45031. * Allows using the bump map in parallax occlusion mode.
  45032. */
  45033. useParallaxOcclusion: boolean;
  45034. /**
  45035. * Controls the scale bias of the parallax mode.
  45036. */
  45037. parallaxScaleBias: number;
  45038. /**
  45039. * If sets to true, disables all the lights affecting the material.
  45040. */
  45041. disableLighting: boolean;
  45042. /**
  45043. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45044. */
  45045. forceIrradianceInFragment: boolean;
  45046. /**
  45047. * Number of Simultaneous lights allowed on the material.
  45048. */
  45049. maxSimultaneousLights: number;
  45050. /**
  45051. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45052. */
  45053. invertNormalMapX: boolean;
  45054. /**
  45055. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45056. */
  45057. invertNormalMapY: boolean;
  45058. /**
  45059. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45060. */
  45061. twoSidedLighting: boolean;
  45062. /**
  45063. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45064. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45065. */
  45066. useAlphaFresnel: boolean;
  45067. /**
  45068. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45069. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45070. */
  45071. useLinearAlphaFresnel: boolean;
  45072. /**
  45073. * Let user defines the brdf lookup texture used for IBL.
  45074. * A default 8bit version is embedded but you could point at :
  45075. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45076. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45077. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45078. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45079. */
  45080. environmentBRDFTexture: Nullable<BaseTexture>;
  45081. /**
  45082. * Force normal to face away from face.
  45083. */
  45084. forceNormalForward: boolean;
  45085. /**
  45086. * Enables specular anti aliasing in the PBR shader.
  45087. * It will both interacts on the Geometry for analytical and IBL lighting.
  45088. * It also prefilter the roughness map based on the bump values.
  45089. */
  45090. enableSpecularAntiAliasing: boolean;
  45091. /**
  45092. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45093. * makes the reflect vector face the model (under horizon).
  45094. */
  45095. useHorizonOcclusion: boolean;
  45096. /**
  45097. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45098. * too much the area relying on ambient texture to define their ambient occlusion.
  45099. */
  45100. useRadianceOcclusion: boolean;
  45101. /**
  45102. * If set to true, no lighting calculations will be applied.
  45103. */
  45104. unlit: boolean;
  45105. /**
  45106. * Gets the image processing configuration used either in this material.
  45107. */
  45108. /**
  45109. * Sets the Default image processing configuration used either in the this material.
  45110. *
  45111. * If sets to null, the scene one is in use.
  45112. */
  45113. imageProcessingConfiguration: ImageProcessingConfiguration;
  45114. /**
  45115. * Gets wether the color curves effect is enabled.
  45116. */
  45117. /**
  45118. * Sets wether the color curves effect is enabled.
  45119. */
  45120. cameraColorCurvesEnabled: boolean;
  45121. /**
  45122. * Gets wether the color grading effect is enabled.
  45123. */
  45124. /**
  45125. * Gets wether the color grading effect is enabled.
  45126. */
  45127. cameraColorGradingEnabled: boolean;
  45128. /**
  45129. * Gets wether tonemapping is enabled or not.
  45130. */
  45131. /**
  45132. * Sets wether tonemapping is enabled or not
  45133. */
  45134. cameraToneMappingEnabled: boolean;
  45135. /**
  45136. * The camera exposure used on this material.
  45137. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45138. * This corresponds to a photographic exposure.
  45139. */
  45140. /**
  45141. * The camera exposure used on this material.
  45142. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45143. * This corresponds to a photographic exposure.
  45144. */
  45145. cameraExposure: number;
  45146. /**
  45147. * Gets The camera contrast used on this material.
  45148. */
  45149. /**
  45150. * Sets The camera contrast used on this material.
  45151. */
  45152. cameraContrast: number;
  45153. /**
  45154. * Gets the Color Grading 2D Lookup Texture.
  45155. */
  45156. /**
  45157. * Sets the Color Grading 2D Lookup Texture.
  45158. */
  45159. cameraColorGradingTexture: Nullable<BaseTexture>;
  45160. /**
  45161. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45162. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45163. * 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;
  45164. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45165. */
  45166. /**
  45167. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45168. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45169. * 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;
  45170. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45171. */
  45172. cameraColorCurves: Nullable<ColorCurves>;
  45173. /**
  45174. * Instantiates a new PBRMaterial instance.
  45175. *
  45176. * @param name The material name
  45177. * @param scene The scene the material will be use in.
  45178. */
  45179. constructor(name: string, scene: Scene);
  45180. /**
  45181. * Returns the name of this material class.
  45182. */
  45183. getClassName(): string;
  45184. /**
  45185. * Makes a duplicate of the current material.
  45186. * @param name - name to use for the new material.
  45187. */
  45188. clone(name: string): PBRMaterial;
  45189. /**
  45190. * Serializes this PBR Material.
  45191. * @returns - An object with the serialized material.
  45192. */
  45193. serialize(): any;
  45194. /**
  45195. * Parses a PBR Material from a serialized object.
  45196. * @param source - Serialized object.
  45197. * @param scene - BJS scene instance.
  45198. * @param rootUrl - url for the scene object
  45199. * @returns - PBRMaterial
  45200. */
  45201. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45202. }
  45203. }
  45204. declare module BABYLON {
  45205. /**
  45206. * Direct draw surface info
  45207. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45208. */
  45209. export interface DDSInfo {
  45210. /**
  45211. * Width of the texture
  45212. */
  45213. width: number;
  45214. /**
  45215. * Width of the texture
  45216. */
  45217. height: number;
  45218. /**
  45219. * Number of Mipmaps for the texture
  45220. * @see https://en.wikipedia.org/wiki/Mipmap
  45221. */
  45222. mipmapCount: number;
  45223. /**
  45224. * If the textures format is a known fourCC format
  45225. * @see https://www.fourcc.org/
  45226. */
  45227. isFourCC: boolean;
  45228. /**
  45229. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45230. */
  45231. isRGB: boolean;
  45232. /**
  45233. * If the texture is a lumincance format
  45234. */
  45235. isLuminance: boolean;
  45236. /**
  45237. * If this is a cube texture
  45238. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45239. */
  45240. isCube: boolean;
  45241. /**
  45242. * If the texture is a compressed format eg. FOURCC_DXT1
  45243. */
  45244. isCompressed: boolean;
  45245. /**
  45246. * The dxgiFormat of the texture
  45247. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45248. */
  45249. dxgiFormat: number;
  45250. /**
  45251. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45252. */
  45253. textureType: number;
  45254. /**
  45255. * Sphericle polynomial created for the dds texture
  45256. */
  45257. sphericalPolynomial?: SphericalPolynomial;
  45258. }
  45259. /**
  45260. * Class used to provide DDS decompression tools
  45261. */
  45262. export class DDSTools {
  45263. /**
  45264. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45265. */
  45266. static StoreLODInAlphaChannel: boolean;
  45267. /**
  45268. * Gets DDS information from an array buffer
  45269. * @param arrayBuffer defines the array buffer to read data from
  45270. * @returns the DDS information
  45271. */
  45272. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45273. private static _FloatView;
  45274. private static _Int32View;
  45275. private static _ToHalfFloat;
  45276. private static _FromHalfFloat;
  45277. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45278. private static _GetHalfFloatRGBAArrayBuffer;
  45279. private static _GetFloatRGBAArrayBuffer;
  45280. private static _GetFloatAsUIntRGBAArrayBuffer;
  45281. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45282. private static _GetRGBAArrayBuffer;
  45283. private static _ExtractLongWordOrder;
  45284. private static _GetRGBArrayBuffer;
  45285. private static _GetLuminanceArrayBuffer;
  45286. /**
  45287. * Uploads DDS Levels to a Babylon Texture
  45288. * @hidden
  45289. */
  45290. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45291. }
  45292. interface Engine {
  45293. /**
  45294. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45295. * @param rootUrl defines the url where the file to load is located
  45296. * @param scene defines the current scene
  45297. * @param lodScale defines scale to apply to the mip map selection
  45298. * @param lodOffset defines offset to apply to the mip map selection
  45299. * @param onLoad defines an optional callback raised when the texture is loaded
  45300. * @param onError defines an optional callback raised if there is an issue to load the texture
  45301. * @param format defines the format of the data
  45302. * @param forcedExtension defines the extension to use to pick the right loader
  45303. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45304. * @returns the cube texture as an InternalTexture
  45305. */
  45306. 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;
  45307. }
  45308. }
  45309. declare module BABYLON {
  45310. /**
  45311. * Implementation of the DDS Texture Loader.
  45312. * @hidden
  45313. */
  45314. export class _DDSTextureLoader implements IInternalTextureLoader {
  45315. /**
  45316. * Defines wether the loader supports cascade loading the different faces.
  45317. */
  45318. readonly supportCascades: boolean;
  45319. /**
  45320. * This returns if the loader support the current file information.
  45321. * @param extension defines the file extension of the file being loaded
  45322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45323. * @param fallback defines the fallback internal texture if any
  45324. * @param isBase64 defines whether the texture is encoded as a base64
  45325. * @param isBuffer defines whether the texture data are stored as a buffer
  45326. * @returns true if the loader can load the specified file
  45327. */
  45328. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45329. /**
  45330. * Transform the url before loading if required.
  45331. * @param rootUrl the url of the texture
  45332. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45333. * @returns the transformed texture
  45334. */
  45335. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45336. /**
  45337. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45338. * @param rootUrl the url of the texture
  45339. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45340. * @returns the fallback texture
  45341. */
  45342. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45343. /**
  45344. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45345. * @param data contains the texture data
  45346. * @param texture defines the BabylonJS internal texture
  45347. * @param createPolynomials will be true if polynomials have been requested
  45348. * @param onLoad defines the callback to trigger once the texture is ready
  45349. * @param onError defines the callback to trigger in case of error
  45350. */
  45351. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45352. /**
  45353. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45354. * @param data contains the texture data
  45355. * @param texture defines the BabylonJS internal texture
  45356. * @param callback defines the method to call once ready to upload
  45357. */
  45358. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45359. }
  45360. }
  45361. declare module BABYLON {
  45362. /** @hidden */
  45363. export var rgbdEncodePixelShader: {
  45364. name: string;
  45365. shader: string;
  45366. };
  45367. }
  45368. declare module BABYLON {
  45369. /**
  45370. * Raw texture data and descriptor sufficient for WebGL texture upload
  45371. */
  45372. export interface EnvironmentTextureInfo {
  45373. /**
  45374. * Version of the environment map
  45375. */
  45376. version: number;
  45377. /**
  45378. * Width of image
  45379. */
  45380. width: number;
  45381. /**
  45382. * Irradiance information stored in the file.
  45383. */
  45384. irradiance: any;
  45385. /**
  45386. * Specular information stored in the file.
  45387. */
  45388. specular: any;
  45389. }
  45390. /**
  45391. * Sets of helpers addressing the serialization and deserialization of environment texture
  45392. * stored in a BabylonJS env file.
  45393. * Those files are usually stored as .env files.
  45394. */
  45395. export class EnvironmentTextureTools {
  45396. /**
  45397. * Magic number identifying the env file.
  45398. */
  45399. private static _MagicBytes;
  45400. /**
  45401. * Gets the environment info from an env file.
  45402. * @param data The array buffer containing the .env bytes.
  45403. * @returns the environment file info (the json header) if successfully parsed.
  45404. */
  45405. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45406. /**
  45407. * Creates an environment texture from a loaded cube texture.
  45408. * @param texture defines the cube texture to convert in env file
  45409. * @return a promise containing the environment data if succesfull.
  45410. */
  45411. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45412. /**
  45413. * Creates a JSON representation of the spherical data.
  45414. * @param texture defines the texture containing the polynomials
  45415. * @return the JSON representation of the spherical info
  45416. */
  45417. private static _CreateEnvTextureIrradiance;
  45418. /**
  45419. * Uploads the texture info contained in the env file to the GPU.
  45420. * @param texture defines the internal texture to upload to
  45421. * @param arrayBuffer defines the buffer cotaining the data to load
  45422. * @param info defines the texture info retrieved through the GetEnvInfo method
  45423. * @returns a promise
  45424. */
  45425. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45426. /**
  45427. * Uploads the levels of image data to the GPU.
  45428. * @param texture defines the internal texture to upload to
  45429. * @param imageData defines the array buffer views of image data [mipmap][face]
  45430. * @returns a promise
  45431. */
  45432. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45433. /**
  45434. * Uploads spherical polynomials information to the texture.
  45435. * @param texture defines the texture we are trying to upload the information to
  45436. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45437. */
  45438. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45439. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45440. }
  45441. }
  45442. declare module BABYLON {
  45443. /**
  45444. * Implementation of the ENV Texture Loader.
  45445. * @hidden
  45446. */
  45447. export class _ENVTextureLoader implements IInternalTextureLoader {
  45448. /**
  45449. * Defines wether the loader supports cascade loading the different faces.
  45450. */
  45451. readonly supportCascades: boolean;
  45452. /**
  45453. * This returns if the loader support the current file information.
  45454. * @param extension defines the file extension of the file being loaded
  45455. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45456. * @param fallback defines the fallback internal texture if any
  45457. * @param isBase64 defines whether the texture is encoded as a base64
  45458. * @param isBuffer defines whether the texture data are stored as a buffer
  45459. * @returns true if the loader can load the specified file
  45460. */
  45461. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45462. /**
  45463. * Transform the url before loading if required.
  45464. * @param rootUrl the url of the texture
  45465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45466. * @returns the transformed texture
  45467. */
  45468. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45469. /**
  45470. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45471. * @param rootUrl the url of the texture
  45472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45473. * @returns the fallback texture
  45474. */
  45475. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45476. /**
  45477. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45478. * @param data contains the texture data
  45479. * @param texture defines the BabylonJS internal texture
  45480. * @param createPolynomials will be true if polynomials have been requested
  45481. * @param onLoad defines the callback to trigger once the texture is ready
  45482. * @param onError defines the callback to trigger in case of error
  45483. */
  45484. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45485. /**
  45486. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45487. * @param data contains the texture data
  45488. * @param texture defines the BabylonJS internal texture
  45489. * @param callback defines the method to call once ready to upload
  45490. */
  45491. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45492. }
  45493. }
  45494. declare module BABYLON {
  45495. /**
  45496. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45497. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45498. */
  45499. export class KhronosTextureContainer {
  45500. /** contents of the KTX container file */
  45501. arrayBuffer: any;
  45502. private static HEADER_LEN;
  45503. private static COMPRESSED_2D;
  45504. private static COMPRESSED_3D;
  45505. private static TEX_2D;
  45506. private static TEX_3D;
  45507. /**
  45508. * Gets the openGL type
  45509. */
  45510. glType: number;
  45511. /**
  45512. * Gets the openGL type size
  45513. */
  45514. glTypeSize: number;
  45515. /**
  45516. * Gets the openGL format
  45517. */
  45518. glFormat: number;
  45519. /**
  45520. * Gets the openGL internal format
  45521. */
  45522. glInternalFormat: number;
  45523. /**
  45524. * Gets the base internal format
  45525. */
  45526. glBaseInternalFormat: number;
  45527. /**
  45528. * Gets image width in pixel
  45529. */
  45530. pixelWidth: number;
  45531. /**
  45532. * Gets image height in pixel
  45533. */
  45534. pixelHeight: number;
  45535. /**
  45536. * Gets image depth in pixels
  45537. */
  45538. pixelDepth: number;
  45539. /**
  45540. * Gets the number of array elements
  45541. */
  45542. numberOfArrayElements: number;
  45543. /**
  45544. * Gets the number of faces
  45545. */
  45546. numberOfFaces: number;
  45547. /**
  45548. * Gets the number of mipmap levels
  45549. */
  45550. numberOfMipmapLevels: number;
  45551. /**
  45552. * Gets the bytes of key value data
  45553. */
  45554. bytesOfKeyValueData: number;
  45555. /**
  45556. * Gets the load type
  45557. */
  45558. loadType: number;
  45559. /**
  45560. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45561. */
  45562. isInvalid: boolean;
  45563. /**
  45564. * Creates a new KhronosTextureContainer
  45565. * @param arrayBuffer contents of the KTX container file
  45566. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45567. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45568. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45569. */
  45570. constructor(
  45571. /** contents of the KTX container file */
  45572. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45573. /**
  45574. * Uploads KTX content to a Babylon Texture.
  45575. * It is assumed that the texture has already been created & is currently bound
  45576. * @hidden
  45577. */
  45578. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45579. private _upload2DCompressedLevels;
  45580. }
  45581. }
  45582. declare module BABYLON {
  45583. /**
  45584. * Implementation of the KTX Texture Loader.
  45585. * @hidden
  45586. */
  45587. export class _KTXTextureLoader implements IInternalTextureLoader {
  45588. /**
  45589. * Defines wether the loader supports cascade loading the different faces.
  45590. */
  45591. readonly supportCascades: boolean;
  45592. /**
  45593. * This returns if the loader support the current file information.
  45594. * @param extension defines the file extension of the file being loaded
  45595. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45596. * @param fallback defines the fallback internal texture if any
  45597. * @param isBase64 defines whether the texture is encoded as a base64
  45598. * @param isBuffer defines whether the texture data are stored as a buffer
  45599. * @returns true if the loader can load the specified file
  45600. */
  45601. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45602. /**
  45603. * Transform the url before loading if required.
  45604. * @param rootUrl the url of the texture
  45605. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45606. * @returns the transformed texture
  45607. */
  45608. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45609. /**
  45610. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45611. * @param rootUrl the url of the texture
  45612. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45613. * @returns the fallback texture
  45614. */
  45615. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45616. /**
  45617. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45618. * @param data contains the texture data
  45619. * @param texture defines the BabylonJS internal texture
  45620. * @param createPolynomials will be true if polynomials have been requested
  45621. * @param onLoad defines the callback to trigger once the texture is ready
  45622. * @param onError defines the callback to trigger in case of error
  45623. */
  45624. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45625. /**
  45626. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45627. * @param data contains the texture data
  45628. * @param texture defines the BabylonJS internal texture
  45629. * @param callback defines the method to call once ready to upload
  45630. */
  45631. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45632. }
  45633. }
  45634. declare module BABYLON {
  45635. /** @hidden */
  45636. export var _forceSceneHelpersToBundle: boolean;
  45637. interface Scene {
  45638. /**
  45639. * Creates a default light for the scene.
  45640. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45641. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45642. */
  45643. createDefaultLight(replace?: boolean): void;
  45644. /**
  45645. * Creates a default camera for the scene.
  45646. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45647. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45648. * @param replace has default false, when true replaces the active camera in the scene
  45649. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45650. */
  45651. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45652. /**
  45653. * Creates a default camera and a default light.
  45654. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45655. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45656. * @param replace has the default false, when true replaces the active camera/light in the scene
  45657. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45658. */
  45659. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45660. /**
  45661. * Creates a new sky box
  45662. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45663. * @param environmentTexture defines the texture to use as environment texture
  45664. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45665. * @param scale defines the overall scale of the skybox
  45666. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45667. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45668. * @returns a new mesh holding the sky box
  45669. */
  45670. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45671. /**
  45672. * Creates a new environment
  45673. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45674. * @param options defines the options you can use to configure the environment
  45675. * @returns the new EnvironmentHelper
  45676. */
  45677. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45678. /**
  45679. * Creates a new VREXperienceHelper
  45680. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45681. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45682. * @returns a new VREXperienceHelper
  45683. */
  45684. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45685. /**
  45686. * Creates a new XREXperienceHelper
  45687. * @see http://doc.babylonjs.com/how_to/webxr
  45688. * @returns a promise for a new XREXperienceHelper
  45689. */
  45690. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45691. }
  45692. }
  45693. declare module BABYLON {
  45694. /**
  45695. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45696. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45697. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45698. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45699. */
  45700. export class VideoDome extends TransformNode {
  45701. /**
  45702. * Define the video source as a Monoscopic panoramic 360 video.
  45703. */
  45704. static readonly MODE_MONOSCOPIC: number;
  45705. /**
  45706. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45707. */
  45708. static readonly MODE_TOPBOTTOM: number;
  45709. /**
  45710. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45711. */
  45712. static readonly MODE_SIDEBYSIDE: number;
  45713. private _useDirectMapping;
  45714. /**
  45715. * The video texture being displayed on the sphere
  45716. */
  45717. protected _videoTexture: VideoTexture;
  45718. /**
  45719. * Gets the video texture being displayed on the sphere
  45720. */
  45721. readonly videoTexture: VideoTexture;
  45722. /**
  45723. * The skybox material
  45724. */
  45725. protected _material: BackgroundMaterial;
  45726. /**
  45727. * The surface used for the skybox
  45728. */
  45729. protected _mesh: Mesh;
  45730. /**
  45731. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45732. * Also see the options.resolution property.
  45733. */
  45734. fovMultiplier: number;
  45735. private _videoMode;
  45736. /**
  45737. * Gets or set the current video mode for the video. It can be:
  45738. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45739. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45740. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45741. */
  45742. videoMode: number;
  45743. /**
  45744. * Oberserver used in Stereoscopic VR Mode.
  45745. */
  45746. private _onBeforeCameraRenderObserver;
  45747. /**
  45748. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45749. * @param name Element's name, child elements will append suffixes for their own names.
  45750. * @param urlsOrVideo defines the url(s) or the video element to use
  45751. * @param options An object containing optional or exposed sub element properties
  45752. */
  45753. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45754. resolution?: number;
  45755. clickToPlay?: boolean;
  45756. autoPlay?: boolean;
  45757. loop?: boolean;
  45758. size?: number;
  45759. poster?: string;
  45760. faceForward?: boolean;
  45761. useDirectMapping?: boolean;
  45762. }, scene: Scene);
  45763. private _changeVideoMode;
  45764. /**
  45765. * Releases resources associated with this node.
  45766. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45767. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45768. */
  45769. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45770. }
  45771. }
  45772. declare module BABYLON {
  45773. /**
  45774. * This class can be used to get instrumentation data from a Babylon engine
  45775. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45776. */
  45777. export class EngineInstrumentation implements IDisposable {
  45778. /**
  45779. * Define the instrumented engine.
  45780. */
  45781. engine: Engine;
  45782. private _captureGPUFrameTime;
  45783. private _gpuFrameTimeToken;
  45784. private _gpuFrameTime;
  45785. private _captureShaderCompilationTime;
  45786. private _shaderCompilationTime;
  45787. private _onBeginFrameObserver;
  45788. private _onEndFrameObserver;
  45789. private _onBeforeShaderCompilationObserver;
  45790. private _onAfterShaderCompilationObserver;
  45791. /**
  45792. * Gets the perf counter used for GPU frame time
  45793. */
  45794. readonly gpuFrameTimeCounter: PerfCounter;
  45795. /**
  45796. * Gets the GPU frame time capture status
  45797. */
  45798. /**
  45799. * Enable or disable the GPU frame time capture
  45800. */
  45801. captureGPUFrameTime: boolean;
  45802. /**
  45803. * Gets the perf counter used for shader compilation time
  45804. */
  45805. readonly shaderCompilationTimeCounter: PerfCounter;
  45806. /**
  45807. * Gets the shader compilation time capture status
  45808. */
  45809. /**
  45810. * Enable or disable the shader compilation time capture
  45811. */
  45812. captureShaderCompilationTime: boolean;
  45813. /**
  45814. * Instantiates a new engine instrumentation.
  45815. * This class can be used to get instrumentation data from a Babylon engine
  45816. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45817. * @param engine Defines the engine to instrument
  45818. */
  45819. constructor(
  45820. /**
  45821. * Define the instrumented engine.
  45822. */
  45823. engine: Engine);
  45824. /**
  45825. * Dispose and release associated resources.
  45826. */
  45827. dispose(): void;
  45828. }
  45829. }
  45830. declare module BABYLON {
  45831. /**
  45832. * This class can be used to get instrumentation data from a Babylon engine
  45833. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45834. */
  45835. export class SceneInstrumentation implements IDisposable {
  45836. /**
  45837. * Defines the scene to instrument
  45838. */
  45839. scene: Scene;
  45840. private _captureActiveMeshesEvaluationTime;
  45841. private _activeMeshesEvaluationTime;
  45842. private _captureRenderTargetsRenderTime;
  45843. private _renderTargetsRenderTime;
  45844. private _captureFrameTime;
  45845. private _frameTime;
  45846. private _captureRenderTime;
  45847. private _renderTime;
  45848. private _captureInterFrameTime;
  45849. private _interFrameTime;
  45850. private _captureParticlesRenderTime;
  45851. private _particlesRenderTime;
  45852. private _captureSpritesRenderTime;
  45853. private _spritesRenderTime;
  45854. private _capturePhysicsTime;
  45855. private _physicsTime;
  45856. private _captureAnimationsTime;
  45857. private _animationsTime;
  45858. private _captureCameraRenderTime;
  45859. private _cameraRenderTime;
  45860. private _onBeforeActiveMeshesEvaluationObserver;
  45861. private _onAfterActiveMeshesEvaluationObserver;
  45862. private _onBeforeRenderTargetsRenderObserver;
  45863. private _onAfterRenderTargetsRenderObserver;
  45864. private _onAfterRenderObserver;
  45865. private _onBeforeDrawPhaseObserver;
  45866. private _onAfterDrawPhaseObserver;
  45867. private _onBeforeAnimationsObserver;
  45868. private _onBeforeParticlesRenderingObserver;
  45869. private _onAfterParticlesRenderingObserver;
  45870. private _onBeforeSpritesRenderingObserver;
  45871. private _onAfterSpritesRenderingObserver;
  45872. private _onBeforePhysicsObserver;
  45873. private _onAfterPhysicsObserver;
  45874. private _onAfterAnimationsObserver;
  45875. private _onBeforeCameraRenderObserver;
  45876. private _onAfterCameraRenderObserver;
  45877. /**
  45878. * Gets the perf counter used for active meshes evaluation time
  45879. */
  45880. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45881. /**
  45882. * Gets the active meshes evaluation time capture status
  45883. */
  45884. /**
  45885. * Enable or disable the active meshes evaluation time capture
  45886. */
  45887. captureActiveMeshesEvaluationTime: boolean;
  45888. /**
  45889. * Gets the perf counter used for render targets render time
  45890. */
  45891. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45892. /**
  45893. * Gets the render targets render time capture status
  45894. */
  45895. /**
  45896. * Enable or disable the render targets render time capture
  45897. */
  45898. captureRenderTargetsRenderTime: boolean;
  45899. /**
  45900. * Gets the perf counter used for particles render time
  45901. */
  45902. readonly particlesRenderTimeCounter: PerfCounter;
  45903. /**
  45904. * Gets the particles render time capture status
  45905. */
  45906. /**
  45907. * Enable or disable the particles render time capture
  45908. */
  45909. captureParticlesRenderTime: boolean;
  45910. /**
  45911. * Gets the perf counter used for sprites render time
  45912. */
  45913. readonly spritesRenderTimeCounter: PerfCounter;
  45914. /**
  45915. * Gets the sprites render time capture status
  45916. */
  45917. /**
  45918. * Enable or disable the sprites render time capture
  45919. */
  45920. captureSpritesRenderTime: boolean;
  45921. /**
  45922. * Gets the perf counter used for physics time
  45923. */
  45924. readonly physicsTimeCounter: PerfCounter;
  45925. /**
  45926. * Gets the physics time capture status
  45927. */
  45928. /**
  45929. * Enable or disable the physics time capture
  45930. */
  45931. capturePhysicsTime: boolean;
  45932. /**
  45933. * Gets the perf counter used for animations time
  45934. */
  45935. readonly animationsTimeCounter: PerfCounter;
  45936. /**
  45937. * Gets the animations time capture status
  45938. */
  45939. /**
  45940. * Enable or disable the animations time capture
  45941. */
  45942. captureAnimationsTime: boolean;
  45943. /**
  45944. * Gets the perf counter used for frame time capture
  45945. */
  45946. readonly frameTimeCounter: PerfCounter;
  45947. /**
  45948. * Gets the frame time capture status
  45949. */
  45950. /**
  45951. * Enable or disable the frame time capture
  45952. */
  45953. captureFrameTime: boolean;
  45954. /**
  45955. * Gets the perf counter used for inter-frames time capture
  45956. */
  45957. readonly interFrameTimeCounter: PerfCounter;
  45958. /**
  45959. * Gets the inter-frames time capture status
  45960. */
  45961. /**
  45962. * Enable or disable the inter-frames time capture
  45963. */
  45964. captureInterFrameTime: boolean;
  45965. /**
  45966. * Gets the perf counter used for render time capture
  45967. */
  45968. readonly renderTimeCounter: PerfCounter;
  45969. /**
  45970. * Gets the render time capture status
  45971. */
  45972. /**
  45973. * Enable or disable the render time capture
  45974. */
  45975. captureRenderTime: boolean;
  45976. /**
  45977. * Gets the perf counter used for camera render time capture
  45978. */
  45979. readonly cameraRenderTimeCounter: PerfCounter;
  45980. /**
  45981. * Gets the camera render time capture status
  45982. */
  45983. /**
  45984. * Enable or disable the camera render time capture
  45985. */
  45986. captureCameraRenderTime: boolean;
  45987. /**
  45988. * Gets the perf counter used for draw calls
  45989. */
  45990. readonly drawCallsCounter: PerfCounter;
  45991. /**
  45992. * Instantiates a new scene instrumentation.
  45993. * This class can be used to get instrumentation data from a Babylon engine
  45994. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45995. * @param scene Defines the scene to instrument
  45996. */
  45997. constructor(
  45998. /**
  45999. * Defines the scene to instrument
  46000. */
  46001. scene: Scene);
  46002. /**
  46003. * Dispose and release associated resources.
  46004. */
  46005. dispose(): void;
  46006. }
  46007. }
  46008. declare module BABYLON {
  46009. /** @hidden */
  46010. export var glowMapGenerationPixelShader: {
  46011. name: string;
  46012. shader: string;
  46013. };
  46014. }
  46015. declare module BABYLON {
  46016. /** @hidden */
  46017. export var glowMapGenerationVertexShader: {
  46018. name: string;
  46019. shader: string;
  46020. };
  46021. }
  46022. declare module BABYLON {
  46023. /**
  46024. * Effect layer options. This helps customizing the behaviour
  46025. * of the effect layer.
  46026. */
  46027. export interface IEffectLayerOptions {
  46028. /**
  46029. * Multiplication factor apply to the canvas size to compute the render target size
  46030. * used to generated the objects (the smaller the faster).
  46031. */
  46032. mainTextureRatio: number;
  46033. /**
  46034. * Enforces a fixed size texture to ensure effect stability across devices.
  46035. */
  46036. mainTextureFixedSize?: number;
  46037. /**
  46038. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46039. */
  46040. alphaBlendingMode: number;
  46041. /**
  46042. * The camera attached to the layer.
  46043. */
  46044. camera: Nullable<Camera>;
  46045. /**
  46046. * The rendering group to draw the layer in.
  46047. */
  46048. renderingGroupId: number;
  46049. }
  46050. /**
  46051. * The effect layer Helps adding post process effect blended with the main pass.
  46052. *
  46053. * This can be for instance use to generate glow or higlight effects on the scene.
  46054. *
  46055. * The effect layer class can not be used directly and is intented to inherited from to be
  46056. * customized per effects.
  46057. */
  46058. export abstract class EffectLayer {
  46059. private _vertexBuffers;
  46060. private _indexBuffer;
  46061. private _cachedDefines;
  46062. private _effectLayerMapGenerationEffect;
  46063. private _effectLayerOptions;
  46064. private _mergeEffect;
  46065. protected _scene: Scene;
  46066. protected _engine: Engine;
  46067. protected _maxSize: number;
  46068. protected _mainTextureDesiredSize: ISize;
  46069. protected _mainTexture: RenderTargetTexture;
  46070. protected _shouldRender: boolean;
  46071. protected _postProcesses: PostProcess[];
  46072. protected _textures: BaseTexture[];
  46073. protected _emissiveTextureAndColor: {
  46074. texture: Nullable<BaseTexture>;
  46075. color: Color4;
  46076. };
  46077. /**
  46078. * The name of the layer
  46079. */
  46080. name: string;
  46081. /**
  46082. * The clear color of the texture used to generate the glow map.
  46083. */
  46084. neutralColor: Color4;
  46085. /**
  46086. * Specifies wether the highlight layer is enabled or not.
  46087. */
  46088. isEnabled: boolean;
  46089. /**
  46090. * Gets the camera attached to the layer.
  46091. */
  46092. readonly camera: Nullable<Camera>;
  46093. /**
  46094. * Gets the rendering group id the layer should render in.
  46095. */
  46096. readonly renderingGroupId: number;
  46097. /**
  46098. * An event triggered when the effect layer has been disposed.
  46099. */
  46100. onDisposeObservable: Observable<EffectLayer>;
  46101. /**
  46102. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46103. */
  46104. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46105. /**
  46106. * An event triggered when the generated texture is being merged in the scene.
  46107. */
  46108. onBeforeComposeObservable: Observable<EffectLayer>;
  46109. /**
  46110. * An event triggered when the generated texture has been merged in the scene.
  46111. */
  46112. onAfterComposeObservable: Observable<EffectLayer>;
  46113. /**
  46114. * An event triggered when the efffect layer changes its size.
  46115. */
  46116. onSizeChangedObservable: Observable<EffectLayer>;
  46117. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46118. /**
  46119. * Instantiates a new effect Layer and references it in the scene.
  46120. * @param name The name of the layer
  46121. * @param scene The scene to use the layer in
  46122. */
  46123. constructor(
  46124. /** The Friendly of the effect in the scene */
  46125. name: string, scene: Scene);
  46126. /**
  46127. * Get the effect name of the layer.
  46128. * @return The effect name
  46129. */
  46130. abstract getEffectName(): string;
  46131. /**
  46132. * Checks for the readiness of the element composing the layer.
  46133. * @param subMesh the mesh to check for
  46134. * @param useInstances specify wether or not to use instances to render the mesh
  46135. * @return true if ready otherwise, false
  46136. */
  46137. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46138. /**
  46139. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46140. * @returns true if the effect requires stencil during the main canvas render pass.
  46141. */
  46142. abstract needStencil(): boolean;
  46143. /**
  46144. * Create the merge effect. This is the shader use to blit the information back
  46145. * to the main canvas at the end of the scene rendering.
  46146. * @returns The effect containing the shader used to merge the effect on the main canvas
  46147. */
  46148. protected abstract _createMergeEffect(): Effect;
  46149. /**
  46150. * Creates the render target textures and post processes used in the effect layer.
  46151. */
  46152. protected abstract _createTextureAndPostProcesses(): void;
  46153. /**
  46154. * Implementation specific of rendering the generating effect on the main canvas.
  46155. * @param effect The effect used to render through
  46156. */
  46157. protected abstract _internalRender(effect: Effect): void;
  46158. /**
  46159. * Sets the required values for both the emissive texture and and the main color.
  46160. */
  46161. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46162. /**
  46163. * Free any resources and references associated to a mesh.
  46164. * Internal use
  46165. * @param mesh The mesh to free.
  46166. */
  46167. abstract _disposeMesh(mesh: Mesh): void;
  46168. /**
  46169. * Serializes this layer (Glow or Highlight for example)
  46170. * @returns a serialized layer object
  46171. */
  46172. abstract serialize?(): any;
  46173. /**
  46174. * Initializes the effect layer with the required options.
  46175. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46176. */
  46177. protected _init(options: Partial<IEffectLayerOptions>): void;
  46178. /**
  46179. * Generates the index buffer of the full screen quad blending to the main canvas.
  46180. */
  46181. private _generateIndexBuffer;
  46182. /**
  46183. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46184. */
  46185. private _generateVertexBuffer;
  46186. /**
  46187. * Sets the main texture desired size which is the closest power of two
  46188. * of the engine canvas size.
  46189. */
  46190. private _setMainTextureSize;
  46191. /**
  46192. * Creates the main texture for the effect layer.
  46193. */
  46194. protected _createMainTexture(): void;
  46195. /**
  46196. * Adds specific effects defines.
  46197. * @param defines The defines to add specifics to.
  46198. */
  46199. protected _addCustomEffectDefines(defines: string[]): void;
  46200. /**
  46201. * Checks for the readiness of the element composing the layer.
  46202. * @param subMesh the mesh to check for
  46203. * @param useInstances specify wether or not to use instances to render the mesh
  46204. * @param emissiveTexture the associated emissive texture used to generate the glow
  46205. * @return true if ready otherwise, false
  46206. */
  46207. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46208. /**
  46209. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46210. */
  46211. render(): void;
  46212. /**
  46213. * Determine if a given mesh will be used in the current effect.
  46214. * @param mesh mesh to test
  46215. * @returns true if the mesh will be used
  46216. */
  46217. hasMesh(mesh: AbstractMesh): boolean;
  46218. /**
  46219. * Returns true if the layer contains information to display, otherwise false.
  46220. * @returns true if the glow layer should be rendered
  46221. */
  46222. shouldRender(): boolean;
  46223. /**
  46224. * Returns true if the mesh should render, otherwise false.
  46225. * @param mesh The mesh to render
  46226. * @returns true if it should render otherwise false
  46227. */
  46228. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46229. /**
  46230. * Returns true if the mesh can be rendered, otherwise false.
  46231. * @param mesh The mesh to render
  46232. * @param material The material used on the mesh
  46233. * @returns true if it can be rendered otherwise false
  46234. */
  46235. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46236. /**
  46237. * Returns true if the mesh should render, otherwise false.
  46238. * @param mesh The mesh to render
  46239. * @returns true if it should render otherwise false
  46240. */
  46241. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46242. /**
  46243. * Renders the submesh passed in parameter to the generation map.
  46244. */
  46245. protected _renderSubMesh(subMesh: SubMesh): void;
  46246. /**
  46247. * Rebuild the required buffers.
  46248. * @hidden Internal use only.
  46249. */ rebuild(): void;
  46250. /**
  46251. * Dispose only the render target textures and post process.
  46252. */
  46253. private _disposeTextureAndPostProcesses;
  46254. /**
  46255. * Dispose the highlight layer and free resources.
  46256. */
  46257. dispose(): void;
  46258. /**
  46259. * Gets the class name of the effect layer
  46260. * @returns the string with the class name of the effect layer
  46261. */
  46262. getClassName(): string;
  46263. /**
  46264. * Creates an effect layer from parsed effect layer data
  46265. * @param parsedEffectLayer defines effect layer data
  46266. * @param scene defines the current scene
  46267. * @param rootUrl defines the root URL containing the effect layer information
  46268. * @returns a parsed effect Layer
  46269. */
  46270. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46271. }
  46272. }
  46273. declare module BABYLON {
  46274. interface AbstractScene {
  46275. /**
  46276. * The list of effect layers (highlights/glow) added to the scene
  46277. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46278. * @see http://doc.babylonjs.com/how_to/glow_layer
  46279. */
  46280. effectLayers: Array<EffectLayer>;
  46281. /**
  46282. * Removes the given effect layer from this scene.
  46283. * @param toRemove defines the effect layer to remove
  46284. * @returns the index of the removed effect layer
  46285. */
  46286. removeEffectLayer(toRemove: EffectLayer): number;
  46287. /**
  46288. * Adds the given effect layer to this scene
  46289. * @param newEffectLayer defines the effect layer to add
  46290. */
  46291. addEffectLayer(newEffectLayer: EffectLayer): void;
  46292. }
  46293. /**
  46294. * Defines the layer scene component responsible to manage any effect layers
  46295. * in a given scene.
  46296. */
  46297. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46298. /**
  46299. * The component name helpfull to identify the component in the list of scene components.
  46300. */
  46301. readonly name: string;
  46302. /**
  46303. * The scene the component belongs to.
  46304. */
  46305. scene: Scene;
  46306. private _engine;
  46307. private _renderEffects;
  46308. private _needStencil;
  46309. private _previousStencilState;
  46310. /**
  46311. * Creates a new instance of the component for the given scene
  46312. * @param scene Defines the scene to register the component in
  46313. */
  46314. constructor(scene: Scene);
  46315. /**
  46316. * Registers the component in a given scene
  46317. */
  46318. register(): void;
  46319. /**
  46320. * Rebuilds the elements related to this component in case of
  46321. * context lost for instance.
  46322. */
  46323. rebuild(): void;
  46324. /**
  46325. * Serializes the component data to the specified json object
  46326. * @param serializationObject The object to serialize to
  46327. */
  46328. serialize(serializationObject: any): void;
  46329. /**
  46330. * Adds all the element from the container to the scene
  46331. * @param container the container holding the elements
  46332. */
  46333. addFromContainer(container: AbstractScene): void;
  46334. /**
  46335. * Removes all the elements in the container from the scene
  46336. * @param container contains the elements to remove
  46337. * @param dispose if the removed element should be disposed (default: false)
  46338. */
  46339. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46340. /**
  46341. * Disposes the component and the associated ressources.
  46342. */
  46343. dispose(): void;
  46344. private _isReadyForMesh;
  46345. private _renderMainTexture;
  46346. private _setStencil;
  46347. private _setStencilBack;
  46348. private _draw;
  46349. private _drawCamera;
  46350. private _drawRenderingGroup;
  46351. }
  46352. }
  46353. declare module BABYLON {
  46354. /** @hidden */
  46355. export var glowMapMergePixelShader: {
  46356. name: string;
  46357. shader: string;
  46358. };
  46359. }
  46360. declare module BABYLON {
  46361. /** @hidden */
  46362. export var glowMapMergeVertexShader: {
  46363. name: string;
  46364. shader: string;
  46365. };
  46366. }
  46367. declare module BABYLON {
  46368. interface AbstractScene {
  46369. /**
  46370. * Return a the first highlight layer of the scene with a given name.
  46371. * @param name The name of the highlight layer to look for.
  46372. * @return The highlight layer if found otherwise null.
  46373. */
  46374. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46375. }
  46376. /**
  46377. * Glow layer options. This helps customizing the behaviour
  46378. * of the glow layer.
  46379. */
  46380. export interface IGlowLayerOptions {
  46381. /**
  46382. * Multiplication factor apply to the canvas size to compute the render target size
  46383. * used to generated the glowing objects (the smaller the faster).
  46384. */
  46385. mainTextureRatio: number;
  46386. /**
  46387. * Enforces a fixed size texture to ensure resize independant blur.
  46388. */
  46389. mainTextureFixedSize?: number;
  46390. /**
  46391. * How big is the kernel of the blur texture.
  46392. */
  46393. blurKernelSize: number;
  46394. /**
  46395. * The camera attached to the layer.
  46396. */
  46397. camera: Nullable<Camera>;
  46398. /**
  46399. * Enable MSAA by chosing the number of samples.
  46400. */
  46401. mainTextureSamples?: number;
  46402. /**
  46403. * The rendering group to draw the layer in.
  46404. */
  46405. renderingGroupId: number;
  46406. }
  46407. /**
  46408. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46409. *
  46410. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46411. * glowy meshes to your scene.
  46412. *
  46413. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46414. */
  46415. export class GlowLayer extends EffectLayer {
  46416. /**
  46417. * Effect Name of the layer.
  46418. */
  46419. static readonly EffectName: string;
  46420. /**
  46421. * The default blur kernel size used for the glow.
  46422. */
  46423. static DefaultBlurKernelSize: number;
  46424. /**
  46425. * The default texture size ratio used for the glow.
  46426. */
  46427. static DefaultTextureRatio: number;
  46428. /**
  46429. * Sets the kernel size of the blur.
  46430. */
  46431. /**
  46432. * Gets the kernel size of the blur.
  46433. */
  46434. blurKernelSize: number;
  46435. /**
  46436. * Sets the glow intensity.
  46437. */
  46438. /**
  46439. * Gets the glow intensity.
  46440. */
  46441. intensity: number;
  46442. private _options;
  46443. private _intensity;
  46444. private _horizontalBlurPostprocess1;
  46445. private _verticalBlurPostprocess1;
  46446. private _horizontalBlurPostprocess2;
  46447. private _verticalBlurPostprocess2;
  46448. private _blurTexture1;
  46449. private _blurTexture2;
  46450. private _postProcesses1;
  46451. private _postProcesses2;
  46452. private _includedOnlyMeshes;
  46453. private _excludedMeshes;
  46454. /**
  46455. * Callback used to let the user override the color selection on a per mesh basis
  46456. */
  46457. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46458. /**
  46459. * Callback used to let the user override the texture selection on a per mesh basis
  46460. */
  46461. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46462. /**
  46463. * Instantiates a new glow Layer and references it to the scene.
  46464. * @param name The name of the layer
  46465. * @param scene The scene to use the layer in
  46466. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46467. */
  46468. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46469. /**
  46470. * Get the effect name of the layer.
  46471. * @return The effect name
  46472. */
  46473. getEffectName(): string;
  46474. /**
  46475. * Create the merge effect. This is the shader use to blit the information back
  46476. * to the main canvas at the end of the scene rendering.
  46477. */
  46478. protected _createMergeEffect(): Effect;
  46479. /**
  46480. * Creates the render target textures and post processes used in the glow layer.
  46481. */
  46482. protected _createTextureAndPostProcesses(): void;
  46483. /**
  46484. * Checks for the readiness of the element composing the layer.
  46485. * @param subMesh the mesh to check for
  46486. * @param useInstances specify wether or not to use instances to render the mesh
  46487. * @param emissiveTexture the associated emissive texture used to generate the glow
  46488. * @return true if ready otherwise, false
  46489. */
  46490. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46491. /**
  46492. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46493. */
  46494. needStencil(): boolean;
  46495. /**
  46496. * Returns true if the mesh can be rendered, otherwise false.
  46497. * @param mesh The mesh to render
  46498. * @param material The material used on the mesh
  46499. * @returns true if it can be rendered otherwise false
  46500. */
  46501. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46502. /**
  46503. * Implementation specific of rendering the generating effect on the main canvas.
  46504. * @param effect The effect used to render through
  46505. */
  46506. protected _internalRender(effect: Effect): void;
  46507. /**
  46508. * Sets the required values for both the emissive texture and and the main color.
  46509. */
  46510. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46511. /**
  46512. * Returns true if the mesh should render, otherwise false.
  46513. * @param mesh The mesh to render
  46514. * @returns true if it should render otherwise false
  46515. */
  46516. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46517. /**
  46518. * Adds specific effects defines.
  46519. * @param defines The defines to add specifics to.
  46520. */
  46521. protected _addCustomEffectDefines(defines: string[]): void;
  46522. /**
  46523. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46524. * @param mesh The mesh to exclude from the glow layer
  46525. */
  46526. addExcludedMesh(mesh: Mesh): void;
  46527. /**
  46528. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46529. * @param mesh The mesh to remove
  46530. */
  46531. removeExcludedMesh(mesh: Mesh): void;
  46532. /**
  46533. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46534. * @param mesh The mesh to include in the glow layer
  46535. */
  46536. addIncludedOnlyMesh(mesh: Mesh): void;
  46537. /**
  46538. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46539. * @param mesh The mesh to remove
  46540. */
  46541. removeIncludedOnlyMesh(mesh: Mesh): void;
  46542. /**
  46543. * Determine if a given mesh will be used in the glow layer
  46544. * @param mesh The mesh to test
  46545. * @returns true if the mesh will be highlighted by the current glow layer
  46546. */
  46547. hasMesh(mesh: AbstractMesh): boolean;
  46548. /**
  46549. * Free any resources and references associated to a mesh.
  46550. * Internal use
  46551. * @param mesh The mesh to free.
  46552. * @hidden
  46553. */ disposeMesh(mesh: Mesh): void;
  46554. /**
  46555. * Gets the class name of the effect layer
  46556. * @returns the string with the class name of the effect layer
  46557. */
  46558. getClassName(): string;
  46559. /**
  46560. * Serializes this glow layer
  46561. * @returns a serialized glow layer object
  46562. */
  46563. serialize(): any;
  46564. /**
  46565. * Creates a Glow Layer from parsed glow layer data
  46566. * @param parsedGlowLayer defines glow layer data
  46567. * @param scene defines the current scene
  46568. * @param rootUrl defines the root URL containing the glow layer information
  46569. * @returns a parsed Glow Layer
  46570. */
  46571. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46572. }
  46573. }
  46574. declare module BABYLON {
  46575. /** @hidden */
  46576. export var glowBlurPostProcessPixelShader: {
  46577. name: string;
  46578. shader: string;
  46579. };
  46580. }
  46581. declare module BABYLON {
  46582. interface AbstractScene {
  46583. /**
  46584. * Return a the first highlight layer of the scene with a given name.
  46585. * @param name The name of the highlight layer to look for.
  46586. * @return The highlight layer if found otherwise null.
  46587. */
  46588. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46589. }
  46590. /**
  46591. * Highlight layer options. This helps customizing the behaviour
  46592. * of the highlight layer.
  46593. */
  46594. export interface IHighlightLayerOptions {
  46595. /**
  46596. * Multiplication factor apply to the canvas size to compute the render target size
  46597. * used to generated the glowing objects (the smaller the faster).
  46598. */
  46599. mainTextureRatio: number;
  46600. /**
  46601. * Enforces a fixed size texture to ensure resize independant blur.
  46602. */
  46603. mainTextureFixedSize?: number;
  46604. /**
  46605. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46606. * of the picture to blur (the smaller the faster).
  46607. */
  46608. blurTextureSizeRatio: number;
  46609. /**
  46610. * How big in texel of the blur texture is the vertical blur.
  46611. */
  46612. blurVerticalSize: number;
  46613. /**
  46614. * How big in texel of the blur texture is the horizontal blur.
  46615. */
  46616. blurHorizontalSize: number;
  46617. /**
  46618. * Alpha blending mode used to apply the blur. Default is combine.
  46619. */
  46620. alphaBlendingMode: number;
  46621. /**
  46622. * The camera attached to the layer.
  46623. */
  46624. camera: Nullable<Camera>;
  46625. /**
  46626. * Should we display highlight as a solid stroke?
  46627. */
  46628. isStroke?: boolean;
  46629. /**
  46630. * The rendering group to draw the layer in.
  46631. */
  46632. renderingGroupId: number;
  46633. }
  46634. /**
  46635. * The highlight layer Helps adding a glow effect around a mesh.
  46636. *
  46637. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46638. * glowy meshes to your scene.
  46639. *
  46640. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46641. */
  46642. export class HighlightLayer extends EffectLayer {
  46643. name: string;
  46644. /**
  46645. * Effect Name of the highlight layer.
  46646. */
  46647. static readonly EffectName: string;
  46648. /**
  46649. * The neutral color used during the preparation of the glow effect.
  46650. * This is black by default as the blend operation is a blend operation.
  46651. */
  46652. static NeutralColor: Color4;
  46653. /**
  46654. * Stencil value used for glowing meshes.
  46655. */
  46656. static GlowingMeshStencilReference: number;
  46657. /**
  46658. * Stencil value used for the other meshes in the scene.
  46659. */
  46660. static NormalMeshStencilReference: number;
  46661. /**
  46662. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46663. */
  46664. innerGlow: boolean;
  46665. /**
  46666. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46667. */
  46668. outerGlow: boolean;
  46669. /**
  46670. * Specifies the horizontal size of the blur.
  46671. */
  46672. /**
  46673. * Gets the horizontal size of the blur.
  46674. */
  46675. blurHorizontalSize: number;
  46676. /**
  46677. * Specifies the vertical size of the blur.
  46678. */
  46679. /**
  46680. * Gets the vertical size of the blur.
  46681. */
  46682. blurVerticalSize: number;
  46683. /**
  46684. * An event triggered when the highlight layer is being blurred.
  46685. */
  46686. onBeforeBlurObservable: Observable<HighlightLayer>;
  46687. /**
  46688. * An event triggered when the highlight layer has been blurred.
  46689. */
  46690. onAfterBlurObservable: Observable<HighlightLayer>;
  46691. private _instanceGlowingMeshStencilReference;
  46692. private _options;
  46693. private _downSamplePostprocess;
  46694. private _horizontalBlurPostprocess;
  46695. private _verticalBlurPostprocess;
  46696. private _blurTexture;
  46697. private _meshes;
  46698. private _excludedMeshes;
  46699. /**
  46700. * Instantiates a new highlight Layer and references it to the scene..
  46701. * @param name The name of the layer
  46702. * @param scene The scene to use the layer in
  46703. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46704. */
  46705. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46706. /**
  46707. * Get the effect name of the layer.
  46708. * @return The effect name
  46709. */
  46710. getEffectName(): string;
  46711. /**
  46712. * Create the merge effect. This is the shader use to blit the information back
  46713. * to the main canvas at the end of the scene rendering.
  46714. */
  46715. protected _createMergeEffect(): Effect;
  46716. /**
  46717. * Creates the render target textures and post processes used in the highlight layer.
  46718. */
  46719. protected _createTextureAndPostProcesses(): void;
  46720. /**
  46721. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46722. */
  46723. needStencil(): boolean;
  46724. /**
  46725. * Checks for the readiness of the element composing the layer.
  46726. * @param subMesh the mesh to check for
  46727. * @param useInstances specify wether or not to use instances to render the mesh
  46728. * @param emissiveTexture the associated emissive texture used to generate the glow
  46729. * @return true if ready otherwise, false
  46730. */
  46731. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46732. /**
  46733. * Implementation specific of rendering the generating effect on the main canvas.
  46734. * @param effect The effect used to render through
  46735. */
  46736. protected _internalRender(effect: Effect): void;
  46737. /**
  46738. * Returns true if the layer contains information to display, otherwise false.
  46739. */
  46740. shouldRender(): boolean;
  46741. /**
  46742. * Returns true if the mesh should render, otherwise false.
  46743. * @param mesh The mesh to render
  46744. * @returns true if it should render otherwise false
  46745. */
  46746. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46747. /**
  46748. * Sets the required values for both the emissive texture and and the main color.
  46749. */
  46750. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46751. /**
  46752. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46753. * @param mesh The mesh to exclude from the highlight layer
  46754. */
  46755. addExcludedMesh(mesh: Mesh): void;
  46756. /**
  46757. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46758. * @param mesh The mesh to highlight
  46759. */
  46760. removeExcludedMesh(mesh: Mesh): void;
  46761. /**
  46762. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46763. * @param mesh mesh to test
  46764. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46765. */
  46766. hasMesh(mesh: AbstractMesh): boolean;
  46767. /**
  46768. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46769. * @param mesh The mesh to highlight
  46770. * @param color The color of the highlight
  46771. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46772. */
  46773. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46774. /**
  46775. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46776. * @param mesh The mesh to highlight
  46777. */
  46778. removeMesh(mesh: Mesh): void;
  46779. /**
  46780. * Force the stencil to the normal expected value for none glowing parts
  46781. */
  46782. private _defaultStencilReference;
  46783. /**
  46784. * Free any resources and references associated to a mesh.
  46785. * Internal use
  46786. * @param mesh The mesh to free.
  46787. * @hidden
  46788. */ disposeMesh(mesh: Mesh): void;
  46789. /**
  46790. * Dispose the highlight layer and free resources.
  46791. */
  46792. dispose(): void;
  46793. /**
  46794. * Gets the class name of the effect layer
  46795. * @returns the string with the class name of the effect layer
  46796. */
  46797. getClassName(): string;
  46798. /**
  46799. * Serializes this Highlight layer
  46800. * @returns a serialized Highlight layer object
  46801. */
  46802. serialize(): any;
  46803. /**
  46804. * Creates a Highlight layer from parsed Highlight layer data
  46805. * @param parsedHightlightLayer defines the Highlight layer data
  46806. * @param scene defines the current scene
  46807. * @param rootUrl defines the root URL containing the Highlight layer information
  46808. * @returns a parsed Highlight layer
  46809. */
  46810. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46811. }
  46812. }
  46813. declare module BABYLON {
  46814. /** @hidden */
  46815. export var lensFlarePixelShader: {
  46816. name: string;
  46817. shader: string;
  46818. };
  46819. }
  46820. declare module BABYLON {
  46821. /** @hidden */
  46822. export var lensFlareVertexShader: {
  46823. name: string;
  46824. shader: string;
  46825. };
  46826. }
  46827. declare module BABYLON {
  46828. /**
  46829. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46830. * It is usually composed of several `lensFlare`.
  46831. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46832. */
  46833. export class LensFlareSystem {
  46834. /**
  46835. * Define the name of the lens flare system
  46836. */
  46837. name: string;
  46838. /**
  46839. * List of lens flares used in this system.
  46840. */
  46841. lensFlares: LensFlare[];
  46842. /**
  46843. * Define a limit from the border the lens flare can be visible.
  46844. */
  46845. borderLimit: number;
  46846. /**
  46847. * Define a viewport border we do not want to see the lens flare in.
  46848. */
  46849. viewportBorder: number;
  46850. /**
  46851. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46852. */
  46853. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46854. /**
  46855. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46856. */
  46857. layerMask: number;
  46858. /**
  46859. * Define the id of the lens flare system in the scene.
  46860. * (equal to name by default)
  46861. */
  46862. id: string;
  46863. private _scene;
  46864. private _emitter;
  46865. private _vertexBuffers;
  46866. private _indexBuffer;
  46867. private _effect;
  46868. private _positionX;
  46869. private _positionY;
  46870. private _isEnabled;
  46871. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46872. /**
  46873. * Instantiates a lens flare system.
  46874. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46875. * It is usually composed of several `lensFlare`.
  46876. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46877. * @param name Define the name of the lens flare system in the scene
  46878. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46879. * @param scene Define the scene the lens flare system belongs to
  46880. */
  46881. constructor(
  46882. /**
  46883. * Define the name of the lens flare system
  46884. */
  46885. name: string, emitter: any, scene: Scene);
  46886. /**
  46887. * Define if the lens flare system is enabled.
  46888. */
  46889. isEnabled: boolean;
  46890. /**
  46891. * Get the scene the effects belongs to.
  46892. * @returns the scene holding the lens flare system
  46893. */
  46894. getScene(): Scene;
  46895. /**
  46896. * Get the emitter of the lens flare system.
  46897. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46898. * @returns the emitter of the lens flare system
  46899. */
  46900. getEmitter(): any;
  46901. /**
  46902. * Set the emitter of the lens flare system.
  46903. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46904. * @param newEmitter Define the new emitter of the system
  46905. */
  46906. setEmitter(newEmitter: any): void;
  46907. /**
  46908. * Get the lens flare system emitter position.
  46909. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46910. * @returns the position
  46911. */
  46912. getEmitterPosition(): Vector3;
  46913. /**
  46914. * @hidden
  46915. */
  46916. computeEffectivePosition(globalViewport: Viewport): boolean;
  46917. /** @hidden */ isVisible(): boolean;
  46918. /**
  46919. * @hidden
  46920. */
  46921. render(): boolean;
  46922. /**
  46923. * Dispose and release the lens flare with its associated resources.
  46924. */
  46925. dispose(): void;
  46926. /**
  46927. * Parse a lens flare system from a JSON repressentation
  46928. * @param parsedLensFlareSystem Define the JSON to parse
  46929. * @param scene Define the scene the parsed system should be instantiated in
  46930. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46931. * @returns the parsed system
  46932. */
  46933. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46934. /**
  46935. * Serialize the current Lens Flare System into a JSON representation.
  46936. * @returns the serialized JSON
  46937. */
  46938. serialize(): any;
  46939. }
  46940. }
  46941. declare module BABYLON {
  46942. /**
  46943. * This represents one of the lens effect in a `lensFlareSystem`.
  46944. * It controls one of the indiviual texture used in the effect.
  46945. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46946. */
  46947. export class LensFlare {
  46948. /**
  46949. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46950. */
  46951. size: number;
  46952. /**
  46953. * 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.
  46954. */
  46955. position: number;
  46956. /**
  46957. * Define the lens color.
  46958. */
  46959. color: Color3;
  46960. /**
  46961. * Define the lens texture.
  46962. */
  46963. texture: Nullable<Texture>;
  46964. /**
  46965. * Define the alpha mode to render this particular lens.
  46966. */
  46967. alphaMode: number;
  46968. private _system;
  46969. /**
  46970. * Creates a new Lens Flare.
  46971. * This represents one of the lens effect in a `lensFlareSystem`.
  46972. * It controls one of the indiviual texture used in the effect.
  46973. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46974. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46975. * @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.
  46976. * @param color Define the lens color
  46977. * @param imgUrl Define the lens texture url
  46978. * @param system Define the `lensFlareSystem` this flare is part of
  46979. * @returns The newly created Lens Flare
  46980. */
  46981. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46982. /**
  46983. * Instantiates a new Lens Flare.
  46984. * This represents one of the lens effect in a `lensFlareSystem`.
  46985. * It controls one of the indiviual texture used in the effect.
  46986. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46987. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46988. * @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.
  46989. * @param color Define the lens color
  46990. * @param imgUrl Define the lens texture url
  46991. * @param system Define the `lensFlareSystem` this flare is part of
  46992. */
  46993. constructor(
  46994. /**
  46995. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46996. */
  46997. size: number,
  46998. /**
  46999. * 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.
  47000. */
  47001. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47002. /**
  47003. * Dispose and release the lens flare with its associated resources.
  47004. */
  47005. dispose(): void;
  47006. }
  47007. }
  47008. declare module BABYLON {
  47009. interface AbstractScene {
  47010. /**
  47011. * The list of lens flare system added to the scene
  47012. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47013. */
  47014. lensFlareSystems: Array<LensFlareSystem>;
  47015. /**
  47016. * Removes the given lens flare system from this scene.
  47017. * @param toRemove The lens flare system to remove
  47018. * @returns The index of the removed lens flare system
  47019. */
  47020. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47021. /**
  47022. * Adds the given lens flare system to this scene
  47023. * @param newLensFlareSystem The lens flare system to add
  47024. */
  47025. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47026. /**
  47027. * Gets a lens flare system using its name
  47028. * @param name defines the name to look for
  47029. * @returns the lens flare system or null if not found
  47030. */
  47031. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47032. /**
  47033. * Gets a lens flare system using its id
  47034. * @param id defines the id to look for
  47035. * @returns the lens flare system or null if not found
  47036. */
  47037. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47038. }
  47039. /**
  47040. * Defines the lens flare scene component responsible to manage any lens flares
  47041. * in a given scene.
  47042. */
  47043. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47044. /**
  47045. * The component name helpfull to identify the component in the list of scene components.
  47046. */
  47047. readonly name: string;
  47048. /**
  47049. * The scene the component belongs to.
  47050. */
  47051. scene: Scene;
  47052. /**
  47053. * Creates a new instance of the component for the given scene
  47054. * @param scene Defines the scene to register the component in
  47055. */
  47056. constructor(scene: Scene);
  47057. /**
  47058. * Registers the component in a given scene
  47059. */
  47060. register(): void;
  47061. /**
  47062. * Rebuilds the elements related to this component in case of
  47063. * context lost for instance.
  47064. */
  47065. rebuild(): void;
  47066. /**
  47067. * Adds all the element from the container to the scene
  47068. * @param container the container holding the elements
  47069. */
  47070. addFromContainer(container: AbstractScene): void;
  47071. /**
  47072. * Removes all the elements in the container from the scene
  47073. * @param container contains the elements to remove
  47074. * @param dispose if the removed element should be disposed (default: false)
  47075. */
  47076. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47077. /**
  47078. * Serializes the component data to the specified json object
  47079. * @param serializationObject The object to serialize to
  47080. */
  47081. serialize(serializationObject: any): void;
  47082. /**
  47083. * Disposes the component and the associated ressources.
  47084. */
  47085. dispose(): void;
  47086. private _draw;
  47087. }
  47088. }
  47089. declare module BABYLON {
  47090. /**
  47091. * Defines the shadow generator component responsible to manage any shadow generators
  47092. * in a given scene.
  47093. */
  47094. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47095. /**
  47096. * The component name helpfull to identify the component in the list of scene components.
  47097. */
  47098. readonly name: string;
  47099. /**
  47100. * The scene the component belongs to.
  47101. */
  47102. scene: Scene;
  47103. /**
  47104. * Creates a new instance of the component for the given scene
  47105. * @param scene Defines the scene to register the component in
  47106. */
  47107. constructor(scene: Scene);
  47108. /**
  47109. * Registers the component in a given scene
  47110. */
  47111. register(): void;
  47112. /**
  47113. * Rebuilds the elements related to this component in case of
  47114. * context lost for instance.
  47115. */
  47116. rebuild(): void;
  47117. /**
  47118. * Serializes the component data to the specified json object
  47119. * @param serializationObject The object to serialize to
  47120. */
  47121. serialize(serializationObject: any): void;
  47122. /**
  47123. * Adds all the element from the container to the scene
  47124. * @param container the container holding the elements
  47125. */
  47126. addFromContainer(container: AbstractScene): void;
  47127. /**
  47128. * Removes all the elements in the container from the scene
  47129. * @param container contains the elements to remove
  47130. * @param dispose if the removed element should be disposed (default: false)
  47131. */
  47132. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47133. /**
  47134. * Rebuilds the elements related to this component in case of
  47135. * context lost for instance.
  47136. */
  47137. dispose(): void;
  47138. private _gatherRenderTargets;
  47139. }
  47140. }
  47141. declare module BABYLON {
  47142. /**
  47143. * A point light is a light defined by an unique point in world space.
  47144. * The light is emitted in every direction from this point.
  47145. * A good example of a point light is a standard light bulb.
  47146. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47147. */
  47148. export class PointLight extends ShadowLight {
  47149. private _shadowAngle;
  47150. /**
  47151. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47152. * This specifies what angle the shadow will use to be created.
  47153. *
  47154. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47155. */
  47156. /**
  47157. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47158. * This specifies what angle the shadow will use to be created.
  47159. *
  47160. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47161. */
  47162. shadowAngle: number;
  47163. /**
  47164. * Gets the direction if it has been set.
  47165. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47166. */
  47167. /**
  47168. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47169. */
  47170. direction: Vector3;
  47171. /**
  47172. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47173. * A PointLight emits the light in every direction.
  47174. * It can cast shadows.
  47175. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47176. * ```javascript
  47177. * var pointLight = new PointLight("pl", camera.position, scene);
  47178. * ```
  47179. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47180. * @param name The light friendly name
  47181. * @param position The position of the point light in the scene
  47182. * @param scene The scene the lights belongs to
  47183. */
  47184. constructor(name: string, position: Vector3, scene: Scene);
  47185. /**
  47186. * Returns the string "PointLight"
  47187. * @returns the class name
  47188. */
  47189. getClassName(): string;
  47190. /**
  47191. * Returns the integer 0.
  47192. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47193. */
  47194. getTypeID(): number;
  47195. /**
  47196. * Specifies wether or not the shadowmap should be a cube texture.
  47197. * @returns true if the shadowmap needs to be a cube texture.
  47198. */
  47199. needCube(): boolean;
  47200. /**
  47201. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47202. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47203. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47204. */
  47205. getShadowDirection(faceIndex?: number): Vector3;
  47206. /**
  47207. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47208. * - fov = PI / 2
  47209. * - aspect ratio : 1.0
  47210. * - z-near and far equal to the active camera minZ and maxZ.
  47211. * Returns the PointLight.
  47212. */
  47213. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47214. protected _buildUniformLayout(): void;
  47215. /**
  47216. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47217. * @param effect The effect to update
  47218. * @param lightIndex The index of the light in the effect to update
  47219. * @returns The point light
  47220. */
  47221. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47222. /**
  47223. * Prepares the list of defines specific to the light type.
  47224. * @param defines the list of defines
  47225. * @param lightIndex defines the index of the light for the effect
  47226. */
  47227. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47228. }
  47229. }
  47230. declare module BABYLON {
  47231. /**
  47232. * Header information of HDR texture files.
  47233. */
  47234. export interface HDRInfo {
  47235. /**
  47236. * The height of the texture in pixels.
  47237. */
  47238. height: number;
  47239. /**
  47240. * The width of the texture in pixels.
  47241. */
  47242. width: number;
  47243. /**
  47244. * The index of the beginning of the data in the binary file.
  47245. */
  47246. dataPosition: number;
  47247. }
  47248. /**
  47249. * This groups tools to convert HDR texture to native colors array.
  47250. */
  47251. export class HDRTools {
  47252. private static Ldexp;
  47253. private static Rgbe2float;
  47254. private static readStringLine;
  47255. /**
  47256. * Reads header information from an RGBE texture stored in a native array.
  47257. * More information on this format are available here:
  47258. * https://en.wikipedia.org/wiki/RGBE_image_format
  47259. *
  47260. * @param uint8array The binary file stored in native array.
  47261. * @return The header information.
  47262. */
  47263. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47264. /**
  47265. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47266. * This RGBE texture needs to store the information as a panorama.
  47267. *
  47268. * More information on this format are available here:
  47269. * https://en.wikipedia.org/wiki/RGBE_image_format
  47270. *
  47271. * @param buffer The binary file stored in an array buffer.
  47272. * @param size The expected size of the extracted cubemap.
  47273. * @return The Cube Map information.
  47274. */
  47275. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47276. /**
  47277. * Returns the pixels data extracted from an RGBE texture.
  47278. * This pixels will be stored left to right up to down in the R G B order in one array.
  47279. *
  47280. * More information on this format are available here:
  47281. * https://en.wikipedia.org/wiki/RGBE_image_format
  47282. *
  47283. * @param uint8array The binary file stored in an array buffer.
  47284. * @param hdrInfo The header information of the file.
  47285. * @return The pixels data in RGB right to left up to down order.
  47286. */
  47287. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47288. private static RGBE_ReadPixels_RLE;
  47289. }
  47290. }
  47291. declare module BABYLON {
  47292. /**
  47293. * This represents a texture coming from an HDR input.
  47294. *
  47295. * The only supported format is currently panorama picture stored in RGBE format.
  47296. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47297. */
  47298. export class HDRCubeTexture extends BaseTexture {
  47299. private static _facesMapping;
  47300. private _generateHarmonics;
  47301. private _noMipmap;
  47302. private _textureMatrix;
  47303. private _size;
  47304. private _onLoad;
  47305. private _onError;
  47306. /**
  47307. * The texture URL.
  47308. */
  47309. url: string;
  47310. /**
  47311. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47312. */
  47313. coordinatesMode: number;
  47314. protected _isBlocking: boolean;
  47315. /**
  47316. * Sets wether or not the texture is blocking during loading.
  47317. */
  47318. /**
  47319. * Gets wether or not the texture is blocking during loading.
  47320. */
  47321. isBlocking: boolean;
  47322. protected _rotationY: number;
  47323. /**
  47324. * Sets texture matrix rotation angle around Y axis in radians.
  47325. */
  47326. /**
  47327. * Gets texture matrix rotation angle around Y axis radians.
  47328. */
  47329. rotationY: number;
  47330. /**
  47331. * Gets or sets the center of the bounding box associated with the cube texture
  47332. * It must define where the camera used to render the texture was set
  47333. */
  47334. boundingBoxPosition: Vector3;
  47335. private _boundingBoxSize;
  47336. /**
  47337. * Gets or sets the size of the bounding box associated with the cube texture
  47338. * When defined, the cubemap will switch to local mode
  47339. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47340. * @example https://www.babylonjs-playground.com/#RNASML
  47341. */
  47342. boundingBoxSize: Vector3;
  47343. /**
  47344. * Instantiates an HDRTexture from the following parameters.
  47345. *
  47346. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47347. * @param scene The scene the texture will be used in
  47348. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47349. * @param noMipmap Forces to not generate the mipmap if true
  47350. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47351. * @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)
  47352. * @param reserved Reserved flag for internal use.
  47353. */
  47354. 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>);
  47355. /**
  47356. * Get the current class name of the texture useful for serialization or dynamic coding.
  47357. * @returns "HDRCubeTexture"
  47358. */
  47359. getClassName(): string;
  47360. /**
  47361. * Occurs when the file is raw .hdr file.
  47362. */
  47363. private loadTexture;
  47364. clone(): HDRCubeTexture;
  47365. delayLoad(): void;
  47366. /**
  47367. * Get the texture reflection matrix used to rotate/transform the reflection.
  47368. * @returns the reflection matrix
  47369. */
  47370. getReflectionTextureMatrix(): Matrix;
  47371. /**
  47372. * Set the texture reflection matrix used to rotate/transform the reflection.
  47373. * @param value Define the reflection matrix to set
  47374. */
  47375. setReflectionTextureMatrix(value: Matrix): void;
  47376. /**
  47377. * Parses a JSON representation of an HDR Texture in order to create the texture
  47378. * @param parsedTexture Define the JSON representation
  47379. * @param scene Define the scene the texture should be created in
  47380. * @param rootUrl Define the root url in case we need to load relative dependencies
  47381. * @returns the newly created texture after parsing
  47382. */
  47383. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47384. serialize(): any;
  47385. }
  47386. }
  47387. declare module BABYLON {
  47388. /**
  47389. * Class used to control physics engine
  47390. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47391. */
  47392. export class PhysicsEngine implements IPhysicsEngine {
  47393. private _physicsPlugin;
  47394. /**
  47395. * Global value used to control the smallest number supported by the simulation
  47396. */
  47397. static Epsilon: number;
  47398. private _impostors;
  47399. private _joints;
  47400. /**
  47401. * Gets the gravity vector used by the simulation
  47402. */
  47403. gravity: Vector3;
  47404. /**
  47405. * Factory used to create the default physics plugin.
  47406. * @returns The default physics plugin
  47407. */
  47408. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47409. /**
  47410. * Creates a new Physics Engine
  47411. * @param gravity defines the gravity vector used by the simulation
  47412. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47413. */
  47414. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47415. /**
  47416. * Sets the gravity vector used by the simulation
  47417. * @param gravity defines the gravity vector to use
  47418. */
  47419. setGravity(gravity: Vector3): void;
  47420. /**
  47421. * Set the time step of the physics engine.
  47422. * Default is 1/60.
  47423. * To slow it down, enter 1/600 for example.
  47424. * To speed it up, 1/30
  47425. * @param newTimeStep defines the new timestep to apply to this world.
  47426. */
  47427. setTimeStep(newTimeStep?: number): void;
  47428. /**
  47429. * Get the time step of the physics engine.
  47430. * @returns the current time step
  47431. */
  47432. getTimeStep(): number;
  47433. /**
  47434. * Release all resources
  47435. */
  47436. dispose(): void;
  47437. /**
  47438. * Gets the name of the current physics plugin
  47439. * @returns the name of the plugin
  47440. */
  47441. getPhysicsPluginName(): string;
  47442. /**
  47443. * Adding a new impostor for the impostor tracking.
  47444. * This will be done by the impostor itself.
  47445. * @param impostor the impostor to add
  47446. */
  47447. addImpostor(impostor: PhysicsImpostor): void;
  47448. /**
  47449. * Remove an impostor from the engine.
  47450. * This impostor and its mesh will not longer be updated by the physics engine.
  47451. * @param impostor the impostor to remove
  47452. */
  47453. removeImpostor(impostor: PhysicsImpostor): void;
  47454. /**
  47455. * Add a joint to the physics engine
  47456. * @param mainImpostor defines the main impostor to which the joint is added.
  47457. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47458. * @param joint defines the joint that will connect both impostors.
  47459. */
  47460. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47461. /**
  47462. * Removes a joint from the simulation
  47463. * @param mainImpostor defines the impostor used with the joint
  47464. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47465. * @param joint defines the joint to remove
  47466. */
  47467. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47468. /**
  47469. * Called by the scene. No need to call it.
  47470. * @param delta defines the timespam between frames
  47471. */ step(delta: number): void;
  47472. /**
  47473. * Gets the current plugin used to run the simulation
  47474. * @returns current plugin
  47475. */
  47476. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47477. /**
  47478. * Gets the list of physic impostors
  47479. * @returns an array of PhysicsImpostor
  47480. */
  47481. getImpostors(): Array<PhysicsImpostor>;
  47482. /**
  47483. * Gets the impostor for a physics enabled object
  47484. * @param object defines the object impersonated by the impostor
  47485. * @returns the PhysicsImpostor or null if not found
  47486. */
  47487. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47488. /**
  47489. * Gets the impostor for a physics body object
  47490. * @param body defines physics body used by the impostor
  47491. * @returns the PhysicsImpostor or null if not found
  47492. */
  47493. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47494. /**
  47495. * Does a raycast in the physics world
  47496. * @param from when should the ray start?
  47497. * @param to when should the ray end?
  47498. * @returns PhysicsRaycastResult
  47499. */
  47500. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47501. }
  47502. }
  47503. declare module BABYLON {
  47504. /** @hidden */
  47505. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47506. private _useDeltaForWorldStep;
  47507. world: any;
  47508. name: string;
  47509. private _physicsMaterials;
  47510. private _fixedTimeStep;
  47511. private _cannonRaycastResult;
  47512. private _raycastResult;
  47513. private _removeAfterStep;
  47514. BJSCANNON: any;
  47515. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47516. setGravity(gravity: Vector3): void;
  47517. setTimeStep(timeStep: number): void;
  47518. getTimeStep(): number;
  47519. executeStep(delta: number): void;
  47520. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47521. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47522. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47523. private _processChildMeshes;
  47524. removePhysicsBody(impostor: PhysicsImpostor): void;
  47525. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47526. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47527. private _addMaterial;
  47528. private _checkWithEpsilon;
  47529. private _createShape;
  47530. private _createHeightmap;
  47531. private _minus90X;
  47532. private _plus90X;
  47533. private _tmpPosition;
  47534. private _tmpDeltaPosition;
  47535. private _tmpUnityRotation;
  47536. private _updatePhysicsBodyTransformation;
  47537. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47538. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47539. isSupported(): boolean;
  47540. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47541. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47542. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47543. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47544. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47545. getBodyMass(impostor: PhysicsImpostor): number;
  47546. getBodyFriction(impostor: PhysicsImpostor): number;
  47547. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47548. getBodyRestitution(impostor: PhysicsImpostor): number;
  47549. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47550. sleepBody(impostor: PhysicsImpostor): void;
  47551. wakeUpBody(impostor: PhysicsImpostor): void;
  47552. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47553. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47554. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47555. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47556. getRadius(impostor: PhysicsImpostor): number;
  47557. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47558. dispose(): void;
  47559. private _extendNamespace;
  47560. /**
  47561. * Does a raycast in the physics world
  47562. * @param from when should the ray start?
  47563. * @param to when should the ray end?
  47564. * @returns PhysicsRaycastResult
  47565. */
  47566. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47567. }
  47568. }
  47569. declare module BABYLON {
  47570. /** @hidden */
  47571. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47572. world: any;
  47573. name: string;
  47574. BJSOIMO: any;
  47575. private _raycastResult;
  47576. constructor(iterations?: number, oimoInjection?: any);
  47577. setGravity(gravity: Vector3): void;
  47578. setTimeStep(timeStep: number): void;
  47579. getTimeStep(): number;
  47580. private _tmpImpostorsArray;
  47581. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47582. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47583. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47584. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47585. private _tmpPositionVector;
  47586. removePhysicsBody(impostor: PhysicsImpostor): void;
  47587. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47588. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47589. isSupported(): boolean;
  47590. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47591. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47592. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47593. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47594. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47595. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47596. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47597. getBodyMass(impostor: PhysicsImpostor): number;
  47598. getBodyFriction(impostor: PhysicsImpostor): number;
  47599. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47600. getBodyRestitution(impostor: PhysicsImpostor): number;
  47601. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47602. sleepBody(impostor: PhysicsImpostor): void;
  47603. wakeUpBody(impostor: PhysicsImpostor): void;
  47604. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47605. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47606. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47607. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47608. getRadius(impostor: PhysicsImpostor): number;
  47609. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47610. dispose(): void;
  47611. /**
  47612. * Does a raycast in the physics world
  47613. * @param from when should the ray start?
  47614. * @param to when should the ray end?
  47615. * @returns PhysicsRaycastResult
  47616. */
  47617. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47618. }
  47619. }
  47620. declare module BABYLON {
  47621. /**
  47622. * Class containing static functions to help procedurally build meshes
  47623. */
  47624. export class RibbonBuilder {
  47625. /**
  47626. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47627. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47628. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47629. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47630. * * 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
  47631. * * 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
  47632. * * 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
  47633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47634. * * 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
  47635. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47636. * * 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
  47637. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47638. * * 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
  47639. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47641. * @param name defines the name of the mesh
  47642. * @param options defines the options used to create the mesh
  47643. * @param scene defines the hosting scene
  47644. * @returns the ribbon mesh
  47645. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47646. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47647. */
  47648. static CreateRibbon(name: string, options: {
  47649. pathArray: Vector3[][];
  47650. closeArray?: boolean;
  47651. closePath?: boolean;
  47652. offset?: number;
  47653. updatable?: boolean;
  47654. sideOrientation?: number;
  47655. frontUVs?: Vector4;
  47656. backUVs?: Vector4;
  47657. instance?: Mesh;
  47658. invertUV?: boolean;
  47659. uvs?: Vector2[];
  47660. colors?: Color4[];
  47661. }, scene?: Nullable<Scene>): Mesh;
  47662. }
  47663. }
  47664. declare module BABYLON {
  47665. /**
  47666. * Class containing static functions to help procedurally build meshes
  47667. */
  47668. export class ShapeBuilder {
  47669. /**
  47670. * 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.
  47671. * * 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.
  47672. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47673. * * 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.
  47674. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47675. * * 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
  47676. * * 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
  47677. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47679. * * 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
  47680. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47682. * @param name defines the name of the mesh
  47683. * @param options defines the options used to create the mesh
  47684. * @param scene defines the hosting scene
  47685. * @returns the extruded shape mesh
  47686. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47688. */
  47689. static ExtrudeShape(name: string, options: {
  47690. shape: Vector3[];
  47691. path: Vector3[];
  47692. scale?: number;
  47693. rotation?: number;
  47694. cap?: number;
  47695. updatable?: boolean;
  47696. sideOrientation?: number;
  47697. frontUVs?: Vector4;
  47698. backUVs?: Vector4;
  47699. instance?: Mesh;
  47700. invertUV?: boolean;
  47701. }, scene?: Nullable<Scene>): Mesh;
  47702. /**
  47703. * Creates an custom extruded shape mesh.
  47704. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47705. * * 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.
  47706. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47707. * * 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
  47708. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47709. * * 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
  47710. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47711. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47712. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47713. * * 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
  47714. * * 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
  47715. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47717. * * 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
  47718. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47720. * @param name defines the name of the mesh
  47721. * @param options defines the options used to create the mesh
  47722. * @param scene defines the hosting scene
  47723. * @returns the custom extruded shape mesh
  47724. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47725. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47726. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47727. */
  47728. static ExtrudeShapeCustom(name: string, options: {
  47729. shape: Vector3[];
  47730. path: Vector3[];
  47731. scaleFunction?: any;
  47732. rotationFunction?: any;
  47733. ribbonCloseArray?: boolean;
  47734. ribbonClosePath?: boolean;
  47735. cap?: number;
  47736. updatable?: boolean;
  47737. sideOrientation?: number;
  47738. frontUVs?: Vector4;
  47739. backUVs?: Vector4;
  47740. instance?: Mesh;
  47741. invertUV?: boolean;
  47742. }, scene?: Nullable<Scene>): Mesh;
  47743. private static _ExtrudeShapeGeneric;
  47744. }
  47745. }
  47746. declare module BABYLON {
  47747. /**
  47748. * AmmoJS Physics plugin
  47749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  47750. * @see https://github.com/kripken/ammo.js/
  47751. */
  47752. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  47753. private _useDeltaForWorldStep;
  47754. /**
  47755. * Reference to the Ammo library
  47756. */
  47757. bjsAMMO: any;
  47758. /**
  47759. * Created ammoJS world which physics bodies are added to
  47760. */
  47761. world: any;
  47762. /**
  47763. * Name of the plugin
  47764. */
  47765. name: string;
  47766. private _timeStep;
  47767. private _fixedTimeStep;
  47768. private _maxSteps;
  47769. private _tmpQuaternion;
  47770. private _tmpAmmoTransform;
  47771. private _tmpAmmoQuaternion;
  47772. private _tmpAmmoConcreteContactResultCallback;
  47773. private _collisionConfiguration;
  47774. private _dispatcher;
  47775. private _overlappingPairCache;
  47776. private _solver;
  47777. private _softBodySolver;
  47778. private _tmpAmmoVectorA;
  47779. private _tmpAmmoVectorB;
  47780. private _tmpAmmoVectorC;
  47781. private _tmpAmmoVectorD;
  47782. private _tmpContactCallbackResult;
  47783. private _tmpAmmoVectorRCA;
  47784. private _tmpAmmoVectorRCB;
  47785. private _raycastResult;
  47786. private static readonly DISABLE_COLLISION_FLAG;
  47787. private static readonly KINEMATIC_FLAG;
  47788. private static readonly DISABLE_DEACTIVATION_FLAG;
  47789. /**
  47790. * Initializes the ammoJS plugin
  47791. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  47792. * @param ammoInjection can be used to inject your own ammo reference
  47793. */
  47794. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  47795. /**
  47796. * Sets the gravity of the physics world (m/(s^2))
  47797. * @param gravity Gravity to set
  47798. */
  47799. setGravity(gravity: Vector3): void;
  47800. /**
  47801. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  47802. * @param timeStep timestep to use in seconds
  47803. */
  47804. setTimeStep(timeStep: number): void;
  47805. /**
  47806. * 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)
  47807. * @param fixedTimeStep fixedTimeStep to use in seconds
  47808. */
  47809. setFixedTimeStep(fixedTimeStep: number): void;
  47810. /**
  47811. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  47812. * @param maxSteps the maximum number of steps by the physics engine per frame
  47813. */
  47814. setMaxSteps(maxSteps: number): void;
  47815. /**
  47816. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  47817. * @returns the current timestep in seconds
  47818. */
  47819. getTimeStep(): number;
  47820. private _isImpostorInContact;
  47821. private _isImpostorPairInContact;
  47822. private _stepSimulation;
  47823. /**
  47824. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  47825. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  47826. * After the step the babylon meshes are set to the position of the physics imposters
  47827. * @param delta amount of time to step forward
  47828. * @param impostors array of imposters to update before/after the step
  47829. */
  47830. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47831. /**
  47832. * Update babylon mesh to match physics world object
  47833. * @param impostor imposter to match
  47834. */
  47835. private _afterSoftStep;
  47836. /**
  47837. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47838. * @param impostor imposter to match
  47839. */
  47840. private _ropeStep;
  47841. /**
  47842. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47843. * @param impostor imposter to match
  47844. */
  47845. private _softbodyOrClothStep;
  47846. private _tmpVector;
  47847. private _tmpMatrix;
  47848. /**
  47849. * Applies an impulse on the imposter
  47850. * @param impostor imposter to apply impulse to
  47851. * @param force amount of force to be applied to the imposter
  47852. * @param contactPoint the location to apply the impulse on the imposter
  47853. */
  47854. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47855. /**
  47856. * Applies a force on the imposter
  47857. * @param impostor imposter to apply force
  47858. * @param force amount of force to be applied to the imposter
  47859. * @param contactPoint the location to apply the force on the imposter
  47860. */
  47861. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47862. /**
  47863. * Creates a physics body using the plugin
  47864. * @param impostor the imposter to create the physics body on
  47865. */
  47866. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47867. /**
  47868. * Removes the physics body from the imposter and disposes of the body's memory
  47869. * @param impostor imposter to remove the physics body from
  47870. */
  47871. removePhysicsBody(impostor: PhysicsImpostor): void;
  47872. /**
  47873. * Generates a joint
  47874. * @param impostorJoint the imposter joint to create the joint with
  47875. */
  47876. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47877. /**
  47878. * Removes a joint
  47879. * @param impostorJoint the imposter joint to remove the joint from
  47880. */
  47881. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47882. private _addMeshVerts;
  47883. /**
  47884. * Initialise the soft body vertices to match its object's (mesh) vertices
  47885. * Softbody vertices (nodes) are in world space and to match this
  47886. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  47887. * @param impostor to create the softbody for
  47888. */
  47889. private _softVertexData;
  47890. /**
  47891. * Create an impostor's soft body
  47892. * @param impostor to create the softbody for
  47893. */
  47894. private _createSoftbody;
  47895. /**
  47896. * Create cloth for an impostor
  47897. * @param impostor to create the softbody for
  47898. */
  47899. private _createCloth;
  47900. /**
  47901. * Create rope for an impostor
  47902. * @param impostor to create the softbody for
  47903. */
  47904. private _createRope;
  47905. private _addHullVerts;
  47906. private _createShape;
  47907. /**
  47908. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  47909. * @param impostor imposter containing the physics body and babylon object
  47910. */
  47911. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47912. /**
  47913. * Sets the babylon object's position/rotation from the physics body's position/rotation
  47914. * @param impostor imposter containing the physics body and babylon object
  47915. * @param newPosition new position
  47916. * @param newRotation new rotation
  47917. */
  47918. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47919. /**
  47920. * If this plugin is supported
  47921. * @returns true if its supported
  47922. */
  47923. isSupported(): boolean;
  47924. /**
  47925. * Sets the linear velocity of the physics body
  47926. * @param impostor imposter to set the velocity on
  47927. * @param velocity velocity to set
  47928. */
  47929. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47930. /**
  47931. * Sets the angular velocity of the physics body
  47932. * @param impostor imposter to set the velocity on
  47933. * @param velocity velocity to set
  47934. */
  47935. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47936. /**
  47937. * gets the linear velocity
  47938. * @param impostor imposter to get linear velocity from
  47939. * @returns linear velocity
  47940. */
  47941. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47942. /**
  47943. * gets the angular velocity
  47944. * @param impostor imposter to get angular velocity from
  47945. * @returns angular velocity
  47946. */
  47947. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47948. /**
  47949. * Sets the mass of physics body
  47950. * @param impostor imposter to set the mass on
  47951. * @param mass mass to set
  47952. */
  47953. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47954. /**
  47955. * Gets the mass of the physics body
  47956. * @param impostor imposter to get the mass from
  47957. * @returns mass
  47958. */
  47959. getBodyMass(impostor: PhysicsImpostor): number;
  47960. /**
  47961. * Gets friction of the impostor
  47962. * @param impostor impostor to get friction from
  47963. * @returns friction value
  47964. */
  47965. getBodyFriction(impostor: PhysicsImpostor): number;
  47966. /**
  47967. * Sets friction of the impostor
  47968. * @param impostor impostor to set friction on
  47969. * @param friction friction value
  47970. */
  47971. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47972. /**
  47973. * Gets restitution of the impostor
  47974. * @param impostor impostor to get restitution from
  47975. * @returns restitution value
  47976. */
  47977. getBodyRestitution(impostor: PhysicsImpostor): number;
  47978. /**
  47979. * Sets resitution of the impostor
  47980. * @param impostor impostor to set resitution on
  47981. * @param restitution resitution value
  47982. */
  47983. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47984. /**
  47985. * Gets pressure inside the impostor
  47986. * @param impostor impostor to get pressure from
  47987. * @returns pressure value
  47988. */
  47989. getBodyPressure(impostor: PhysicsImpostor): number;
  47990. /**
  47991. * Sets pressure inside a soft body impostor
  47992. * Cloth and rope must remain 0 pressure
  47993. * @param impostor impostor to set pressure on
  47994. * @param pressure pressure value
  47995. */
  47996. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  47997. /**
  47998. * Gets stiffness of the impostor
  47999. * @param impostor impostor to get stiffness from
  48000. * @returns pressure value
  48001. */
  48002. getBodyStiffness(impostor: PhysicsImpostor): number;
  48003. /**
  48004. * Sets stiffness of the impostor
  48005. * @param impostor impostor to set stiffness on
  48006. * @param stiffness stiffness value from 0 to 1
  48007. */
  48008. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48009. /**
  48010. * Gets velocityIterations of the impostor
  48011. * @param impostor impostor to get velocity iterations from
  48012. * @returns velocityIterations value
  48013. */
  48014. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48015. /**
  48016. * Sets velocityIterations of the impostor
  48017. * @param impostor impostor to set velocity iterations on
  48018. * @param velocityIterations velocityIterations value
  48019. */
  48020. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48021. /**
  48022. * Gets positionIterations of the impostor
  48023. * @param impostor impostor to get position iterations from
  48024. * @returns positionIterations value
  48025. */
  48026. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48027. /**
  48028. * Sets positionIterations of the impostor
  48029. * @param impostor impostor to set position on
  48030. * @param positionIterations positionIterations value
  48031. */
  48032. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48033. /**
  48034. * Append an anchor to a cloth object
  48035. * @param impostor is the cloth impostor to add anchor to
  48036. * @param otherImpostor is the rigid impostor to anchor to
  48037. * @param width ratio across width from 0 to 1
  48038. * @param height ratio up height from 0 to 1
  48039. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48040. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48041. */
  48042. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48043. /**
  48044. * Append an hook to a rope object
  48045. * @param impostor is the rope impostor to add hook to
  48046. * @param otherImpostor is the rigid impostor to hook to
  48047. * @param length ratio along the rope from 0 to 1
  48048. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48049. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48050. */
  48051. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48052. /**
  48053. * Sleeps the physics body and stops it from being active
  48054. * @param impostor impostor to sleep
  48055. */
  48056. sleepBody(impostor: PhysicsImpostor): void;
  48057. /**
  48058. * Activates the physics body
  48059. * @param impostor impostor to activate
  48060. */
  48061. wakeUpBody(impostor: PhysicsImpostor): void;
  48062. /**
  48063. * Updates the distance parameters of the joint
  48064. * @param joint joint to update
  48065. * @param maxDistance maximum distance of the joint
  48066. * @param minDistance minimum distance of the joint
  48067. */
  48068. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48069. /**
  48070. * Sets a motor on the joint
  48071. * @param joint joint to set motor on
  48072. * @param speed speed of the motor
  48073. * @param maxForce maximum force of the motor
  48074. * @param motorIndex index of the motor
  48075. */
  48076. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48077. /**
  48078. * Sets the motors limit
  48079. * @param joint joint to set limit on
  48080. * @param upperLimit upper limit
  48081. * @param lowerLimit lower limit
  48082. */
  48083. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48084. /**
  48085. * Syncs the position and rotation of a mesh with the impostor
  48086. * @param mesh mesh to sync
  48087. * @param impostor impostor to update the mesh with
  48088. */
  48089. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48090. /**
  48091. * Gets the radius of the impostor
  48092. * @param impostor impostor to get radius from
  48093. * @returns the radius
  48094. */
  48095. getRadius(impostor: PhysicsImpostor): number;
  48096. /**
  48097. * Gets the box size of the impostor
  48098. * @param impostor impostor to get box size from
  48099. * @param result the resulting box size
  48100. */
  48101. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48102. /**
  48103. * Disposes of the impostor
  48104. */
  48105. dispose(): void;
  48106. /**
  48107. * Does a raycast in the physics world
  48108. * @param from when should the ray start?
  48109. * @param to when should the ray end?
  48110. * @returns PhysicsRaycastResult
  48111. */
  48112. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48113. }
  48114. }
  48115. declare module BABYLON {
  48116. interface AbstractScene {
  48117. /**
  48118. * The list of reflection probes added to the scene
  48119. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48120. */
  48121. reflectionProbes: Array<ReflectionProbe>;
  48122. /**
  48123. * Removes the given reflection probe from this scene.
  48124. * @param toRemove The reflection probe to remove
  48125. * @returns The index of the removed reflection probe
  48126. */
  48127. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48128. /**
  48129. * Adds the given reflection probe to this scene.
  48130. * @param newReflectionProbe The reflection probe to add
  48131. */
  48132. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48133. }
  48134. /**
  48135. * Class used to generate realtime reflection / refraction cube textures
  48136. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48137. */
  48138. export class ReflectionProbe {
  48139. /** defines the name of the probe */
  48140. name: string;
  48141. private _scene;
  48142. private _renderTargetTexture;
  48143. private _projectionMatrix;
  48144. private _viewMatrix;
  48145. private _target;
  48146. private _add;
  48147. private _attachedMesh;
  48148. private _invertYAxis;
  48149. /** Gets or sets probe position (center of the cube map) */
  48150. position: Vector3;
  48151. /**
  48152. * Creates a new reflection probe
  48153. * @param name defines the name of the probe
  48154. * @param size defines the texture resolution (for each face)
  48155. * @param scene defines the hosting scene
  48156. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48157. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48158. */
  48159. constructor(
  48160. /** defines the name of the probe */
  48161. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48162. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48163. samples: number;
  48164. /** Gets or sets the refresh rate to use (on every frame by default) */
  48165. refreshRate: number;
  48166. /**
  48167. * Gets the hosting scene
  48168. * @returns a Scene
  48169. */
  48170. getScene(): Scene;
  48171. /** Gets the internal CubeTexture used to render to */
  48172. readonly cubeTexture: RenderTargetTexture;
  48173. /** Gets the list of meshes to render */
  48174. readonly renderList: Nullable<AbstractMesh[]>;
  48175. /**
  48176. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48177. * @param mesh defines the mesh to attach to
  48178. */
  48179. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48180. /**
  48181. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48182. * @param renderingGroupId The rendering group id corresponding to its index
  48183. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48184. */
  48185. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48186. /**
  48187. * Clean all associated resources
  48188. */
  48189. dispose(): void;
  48190. /**
  48191. * Converts the reflection probe information to a readable string for debug purpose.
  48192. * @param fullDetails Supports for multiple levels of logging within scene loading
  48193. * @returns the human readable reflection probe info
  48194. */
  48195. toString(fullDetails?: boolean): string;
  48196. /**
  48197. * Get the class name of the relfection probe.
  48198. * @returns "ReflectionProbe"
  48199. */
  48200. getClassName(): string;
  48201. /**
  48202. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48203. * @returns The JSON representation of the texture
  48204. */
  48205. serialize(): any;
  48206. /**
  48207. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48208. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48209. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48210. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48211. * @returns The parsed reflection probe if successful
  48212. */
  48213. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48214. }
  48215. }
  48216. declare module BABYLON {
  48217. /** @hidden */
  48218. export var _BabylonLoaderRegistered: boolean;
  48219. }
  48220. declare module BABYLON {
  48221. /**
  48222. * The Physically based simple base material of BJS.
  48223. *
  48224. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48225. * It is used as the base class for both the specGloss and metalRough conventions.
  48226. */
  48227. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48228. /**
  48229. * Number of Simultaneous lights allowed on the material.
  48230. */
  48231. maxSimultaneousLights: number;
  48232. /**
  48233. * If sets to true, disables all the lights affecting the material.
  48234. */
  48235. disableLighting: boolean;
  48236. /**
  48237. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48238. */
  48239. environmentTexture: BaseTexture;
  48240. /**
  48241. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48242. */
  48243. invertNormalMapX: boolean;
  48244. /**
  48245. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48246. */
  48247. invertNormalMapY: boolean;
  48248. /**
  48249. * Normal map used in the model.
  48250. */
  48251. normalTexture: BaseTexture;
  48252. /**
  48253. * Emissivie color used to self-illuminate the model.
  48254. */
  48255. emissiveColor: Color3;
  48256. /**
  48257. * Emissivie texture used to self-illuminate the model.
  48258. */
  48259. emissiveTexture: BaseTexture;
  48260. /**
  48261. * Occlusion Channel Strenght.
  48262. */
  48263. occlusionStrength: number;
  48264. /**
  48265. * Occlusion Texture of the material (adding extra occlusion effects).
  48266. */
  48267. occlusionTexture: BaseTexture;
  48268. /**
  48269. * Defines the alpha limits in alpha test mode.
  48270. */
  48271. alphaCutOff: number;
  48272. /**
  48273. * Gets the current double sided mode.
  48274. */
  48275. /**
  48276. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48277. */
  48278. doubleSided: boolean;
  48279. /**
  48280. * Stores the pre-calculated light information of a mesh in a texture.
  48281. */
  48282. lightmapTexture: BaseTexture;
  48283. /**
  48284. * If true, the light map contains occlusion information instead of lighting info.
  48285. */
  48286. useLightmapAsShadowmap: boolean;
  48287. /**
  48288. * Instantiates a new PBRMaterial instance.
  48289. *
  48290. * @param name The material name
  48291. * @param scene The scene the material will be use in.
  48292. */
  48293. constructor(name: string, scene: Scene);
  48294. getClassName(): string;
  48295. }
  48296. }
  48297. declare module BABYLON {
  48298. /**
  48299. * The PBR material of BJS following the metal roughness convention.
  48300. *
  48301. * This fits to the PBR convention in the GLTF definition:
  48302. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48303. */
  48304. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48305. /**
  48306. * The base color has two different interpretations depending on the value of metalness.
  48307. * When the material is a metal, the base color is the specific measured reflectance value
  48308. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48309. * of the material.
  48310. */
  48311. baseColor: Color3;
  48312. /**
  48313. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48314. * well as opacity information in the alpha channel.
  48315. */
  48316. baseTexture: BaseTexture;
  48317. /**
  48318. * Specifies the metallic scalar value of the material.
  48319. * Can also be used to scale the metalness values of the metallic texture.
  48320. */
  48321. metallic: number;
  48322. /**
  48323. * Specifies the roughness scalar value of the material.
  48324. * Can also be used to scale the roughness values of the metallic texture.
  48325. */
  48326. roughness: number;
  48327. /**
  48328. * Texture containing both the metallic value in the B channel and the
  48329. * roughness value in the G channel to keep better precision.
  48330. */
  48331. metallicRoughnessTexture: BaseTexture;
  48332. /**
  48333. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48334. *
  48335. * @param name The material name
  48336. * @param scene The scene the material will be use in.
  48337. */
  48338. constructor(name: string, scene: Scene);
  48339. /**
  48340. * Return the currrent class name of the material.
  48341. */
  48342. getClassName(): string;
  48343. /**
  48344. * Makes a duplicate of the current material.
  48345. * @param name - name to use for the new material.
  48346. */
  48347. clone(name: string): PBRMetallicRoughnessMaterial;
  48348. /**
  48349. * Serialize the material to a parsable JSON object.
  48350. */
  48351. serialize(): any;
  48352. /**
  48353. * Parses a JSON object correponding to the serialize function.
  48354. */
  48355. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48356. }
  48357. }
  48358. declare module BABYLON {
  48359. /**
  48360. * The PBR material of BJS following the specular glossiness convention.
  48361. *
  48362. * This fits to the PBR convention in the GLTF definition:
  48363. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48364. */
  48365. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48366. /**
  48367. * Specifies the diffuse color of the material.
  48368. */
  48369. diffuseColor: Color3;
  48370. /**
  48371. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48372. * channel.
  48373. */
  48374. diffuseTexture: BaseTexture;
  48375. /**
  48376. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48377. */
  48378. specularColor: Color3;
  48379. /**
  48380. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48381. */
  48382. glossiness: number;
  48383. /**
  48384. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48385. */
  48386. specularGlossinessTexture: BaseTexture;
  48387. /**
  48388. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48389. *
  48390. * @param name The material name
  48391. * @param scene The scene the material will be use in.
  48392. */
  48393. constructor(name: string, scene: Scene);
  48394. /**
  48395. * Return the currrent class name of the material.
  48396. */
  48397. getClassName(): string;
  48398. /**
  48399. * Makes a duplicate of the current material.
  48400. * @param name - name to use for the new material.
  48401. */
  48402. clone(name: string): PBRSpecularGlossinessMaterial;
  48403. /**
  48404. * Serialize the material to a parsable JSON object.
  48405. */
  48406. serialize(): any;
  48407. /**
  48408. * Parses a JSON object correponding to the serialize function.
  48409. */
  48410. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48411. }
  48412. }
  48413. declare module BABYLON {
  48414. /**
  48415. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48416. * It can help converting any input color in a desired output one. This can then be used to create effects
  48417. * from sepia, black and white to sixties or futuristic rendering...
  48418. *
  48419. * The only supported format is currently 3dl.
  48420. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48421. */
  48422. export class ColorGradingTexture extends BaseTexture {
  48423. /**
  48424. * The current texture matrix. (will always be identity in color grading texture)
  48425. */
  48426. private _textureMatrix;
  48427. /**
  48428. * The texture URL.
  48429. */
  48430. url: string;
  48431. /**
  48432. * Empty line regex stored for GC.
  48433. */
  48434. private static _noneEmptyLineRegex;
  48435. private _engine;
  48436. /**
  48437. * Instantiates a ColorGradingTexture from the following parameters.
  48438. *
  48439. * @param url The location of the color gradind data (currently only supporting 3dl)
  48440. * @param scene The scene the texture will be used in
  48441. */
  48442. constructor(url: string, scene: Scene);
  48443. /**
  48444. * Returns the texture matrix used in most of the material.
  48445. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48446. */
  48447. getTextureMatrix(): Matrix;
  48448. /**
  48449. * Occurs when the file being loaded is a .3dl LUT file.
  48450. */
  48451. private load3dlTexture;
  48452. /**
  48453. * Starts the loading process of the texture.
  48454. */
  48455. private loadTexture;
  48456. /**
  48457. * Clones the color gradind texture.
  48458. */
  48459. clone(): ColorGradingTexture;
  48460. /**
  48461. * Called during delayed load for textures.
  48462. */
  48463. delayLoad(): void;
  48464. /**
  48465. * Parses a color grading texture serialized by Babylon.
  48466. * @param parsedTexture The texture information being parsedTexture
  48467. * @param scene The scene to load the texture in
  48468. * @param rootUrl The root url of the data assets to load
  48469. * @return A color gradind texture
  48470. */
  48471. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48472. /**
  48473. * Serializes the LUT texture to json format.
  48474. */
  48475. serialize(): any;
  48476. }
  48477. }
  48478. declare module BABYLON {
  48479. /**
  48480. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48481. */
  48482. export class EquiRectangularCubeTexture extends BaseTexture {
  48483. /** The six faces of the cube. */
  48484. private static _FacesMapping;
  48485. private _noMipmap;
  48486. private _onLoad;
  48487. private _onError;
  48488. /** The size of the cubemap. */
  48489. private _size;
  48490. /** The buffer of the image. */
  48491. private _buffer;
  48492. /** The width of the input image. */
  48493. private _width;
  48494. /** The height of the input image. */
  48495. private _height;
  48496. /** The URL to the image. */
  48497. url: string;
  48498. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48499. coordinatesMode: number;
  48500. /**
  48501. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48502. * @param url The location of the image
  48503. * @param scene The scene the texture will be used in
  48504. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48505. * @param noMipmap Forces to not generate the mipmap if true
  48506. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48507. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48508. * @param onLoad — defines a callback called when texture is loaded
  48509. * @param onError — defines a callback called if there is an error
  48510. */
  48511. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48512. /**
  48513. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48514. */
  48515. private loadImage;
  48516. /**
  48517. * Convert the image buffer into a cubemap and create a CubeTexture.
  48518. */
  48519. private loadTexture;
  48520. /**
  48521. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48522. * @param buffer The ArrayBuffer that should be converted.
  48523. * @returns The buffer as Float32Array.
  48524. */
  48525. private getFloat32ArrayFromArrayBuffer;
  48526. /**
  48527. * Get the current class name of the texture useful for serialization or dynamic coding.
  48528. * @returns "EquiRectangularCubeTexture"
  48529. */
  48530. getClassName(): string;
  48531. /**
  48532. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48533. * @returns A clone of the current EquiRectangularCubeTexture.
  48534. */
  48535. clone(): EquiRectangularCubeTexture;
  48536. }
  48537. }
  48538. declare module BABYLON {
  48539. /**
  48540. * Based on jsTGALoader - Javascript loader for TGA file
  48541. * By Vincent Thibault
  48542. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48543. */
  48544. export class TGATools {
  48545. private static _TYPE_INDEXED;
  48546. private static _TYPE_RGB;
  48547. private static _TYPE_GREY;
  48548. private static _TYPE_RLE_INDEXED;
  48549. private static _TYPE_RLE_RGB;
  48550. private static _TYPE_RLE_GREY;
  48551. private static _ORIGIN_MASK;
  48552. private static _ORIGIN_SHIFT;
  48553. private static _ORIGIN_BL;
  48554. private static _ORIGIN_BR;
  48555. private static _ORIGIN_UL;
  48556. private static _ORIGIN_UR;
  48557. /**
  48558. * Gets the header of a TGA file
  48559. * @param data defines the TGA data
  48560. * @returns the header
  48561. */
  48562. static GetTGAHeader(data: Uint8Array): any;
  48563. /**
  48564. * Uploads TGA content to a Babylon Texture
  48565. * @hidden
  48566. */
  48567. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48568. /** @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;
  48569. /** @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;
  48570. /** @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;
  48571. /** @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;
  48572. /** @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;
  48573. /** @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;
  48574. }
  48575. }
  48576. declare module BABYLON {
  48577. /**
  48578. * Implementation of the TGA Texture Loader.
  48579. * @hidden
  48580. */
  48581. export class _TGATextureLoader implements IInternalTextureLoader {
  48582. /**
  48583. * Defines wether the loader supports cascade loading the different faces.
  48584. */
  48585. readonly supportCascades: boolean;
  48586. /**
  48587. * This returns if the loader support the current file information.
  48588. * @param extension defines the file extension of the file being loaded
  48589. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48590. * @param fallback defines the fallback internal texture if any
  48591. * @param isBase64 defines whether the texture is encoded as a base64
  48592. * @param isBuffer defines whether the texture data are stored as a buffer
  48593. * @returns true if the loader can load the specified file
  48594. */
  48595. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48596. /**
  48597. * Transform the url before loading if required.
  48598. * @param rootUrl the url of the texture
  48599. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48600. * @returns the transformed texture
  48601. */
  48602. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48603. /**
  48604. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48605. * @param rootUrl the url of the texture
  48606. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48607. * @returns the fallback texture
  48608. */
  48609. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48610. /**
  48611. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48612. * @param data contains the texture data
  48613. * @param texture defines the BabylonJS internal texture
  48614. * @param createPolynomials will be true if polynomials have been requested
  48615. * @param onLoad defines the callback to trigger once the texture is ready
  48616. * @param onError defines the callback to trigger in case of error
  48617. */
  48618. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48619. /**
  48620. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48621. * @param data contains the texture data
  48622. * @param texture defines the BabylonJS internal texture
  48623. * @param callback defines the method to call once ready to upload
  48624. */
  48625. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48626. }
  48627. }
  48628. declare module BABYLON {
  48629. /**
  48630. * 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.
  48631. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48632. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48633. */
  48634. export class CustomProceduralTexture extends ProceduralTexture {
  48635. private _animate;
  48636. private _time;
  48637. private _config;
  48638. private _texturePath;
  48639. /**
  48640. * Instantiates a new Custom Procedural Texture.
  48641. * 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.
  48642. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48643. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48644. * @param name Define the name of the texture
  48645. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48646. * @param size Define the size of the texture to create
  48647. * @param scene Define the scene the texture belongs to
  48648. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48649. * @param generateMipMaps Define if the texture should creates mip maps or not
  48650. */
  48651. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48652. private _loadJson;
  48653. /**
  48654. * Is the texture ready to be used ? (rendered at least once)
  48655. * @returns true if ready, otherwise, false.
  48656. */
  48657. isReady(): boolean;
  48658. /**
  48659. * Render the texture to its associated render target.
  48660. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48661. */
  48662. render(useCameraPostProcess?: boolean): void;
  48663. /**
  48664. * Update the list of dependant textures samplers in the shader.
  48665. */
  48666. updateTextures(): void;
  48667. /**
  48668. * Update the uniform values of the procedural texture in the shader.
  48669. */
  48670. updateShaderUniforms(): void;
  48671. /**
  48672. * Define if the texture animates or not.
  48673. */
  48674. animate: boolean;
  48675. }
  48676. }
  48677. declare module BABYLON {
  48678. /** @hidden */
  48679. export var noisePixelShader: {
  48680. name: string;
  48681. shader: string;
  48682. };
  48683. }
  48684. declare module BABYLON {
  48685. /**
  48686. * Class used to generate noise procedural textures
  48687. */
  48688. export class NoiseProceduralTexture extends ProceduralTexture {
  48689. private _time;
  48690. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48691. brightness: number;
  48692. /** Defines the number of octaves to process */
  48693. octaves: number;
  48694. /** Defines the level of persistence (0.8 by default) */
  48695. persistence: number;
  48696. /** Gets or sets animation speed factor (default is 1) */
  48697. animationSpeedFactor: number;
  48698. /**
  48699. * Creates a new NoiseProceduralTexture
  48700. * @param name defines the name fo the texture
  48701. * @param size defines the size of the texture (default is 256)
  48702. * @param scene defines the hosting scene
  48703. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48704. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48705. */
  48706. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48707. private _updateShaderUniforms;
  48708. protected _getDefines(): string;
  48709. /** Generate the current state of the procedural texture */
  48710. render(useCameraPostProcess?: boolean): void;
  48711. /**
  48712. * Serializes this noise procedural texture
  48713. * @returns a serialized noise procedural texture object
  48714. */
  48715. serialize(): any;
  48716. /**
  48717. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48718. * @param parsedTexture defines parsed texture data
  48719. * @param scene defines the current scene
  48720. * @param rootUrl defines the root URL containing noise procedural texture information
  48721. * @returns a parsed NoiseProceduralTexture
  48722. */
  48723. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48724. }
  48725. }
  48726. declare module BABYLON {
  48727. /**
  48728. * Raw cube texture where the raw buffers are passed in
  48729. */
  48730. export class RawCubeTexture extends CubeTexture {
  48731. /**
  48732. * Creates a cube texture where the raw buffers are passed in.
  48733. * @param scene defines the scene the texture is attached to
  48734. * @param data defines the array of data to use to create each face
  48735. * @param size defines the size of the textures
  48736. * @param format defines the format of the data
  48737. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48738. * @param generateMipMaps defines if the engine should generate the mip levels
  48739. * @param invertY defines if data must be stored with Y axis inverted
  48740. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48741. * @param compression defines the compression used (null by default)
  48742. */
  48743. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48744. /**
  48745. * Updates the raw cube texture.
  48746. * @param data defines the data to store
  48747. * @param format defines the data format
  48748. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48749. * @param invertY defines if data must be stored with Y axis inverted
  48750. * @param compression defines the compression used (null by default)
  48751. * @param level defines which level of the texture to update
  48752. */
  48753. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48754. /**
  48755. * Updates a raw cube texture with RGBD encoded data.
  48756. * @param data defines the array of data [mipmap][face] to use to create each face
  48757. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48758. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48759. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48760. * @returns a promsie that resolves when the operation is complete
  48761. */
  48762. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48763. /**
  48764. * Clones the raw cube texture.
  48765. * @return a new cube texture
  48766. */
  48767. clone(): CubeTexture;
  48768. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48769. }
  48770. }
  48771. declare module BABYLON {
  48772. /**
  48773. * Class used to store 3D textures containing user data
  48774. */
  48775. export class RawTexture3D extends Texture {
  48776. /** Gets or sets the texture format to use */
  48777. format: number;
  48778. private _engine;
  48779. /**
  48780. * Create a new RawTexture3D
  48781. * @param data defines the data of the texture
  48782. * @param width defines the width of the texture
  48783. * @param height defines the height of the texture
  48784. * @param depth defines the depth of the texture
  48785. * @param format defines the texture format to use
  48786. * @param scene defines the hosting scene
  48787. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48788. * @param invertY defines if texture must be stored with Y axis inverted
  48789. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48790. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48791. */
  48792. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48793. /** Gets or sets the texture format to use */
  48794. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48795. /**
  48796. * Update the texture with new data
  48797. * @param data defines the data to store in the texture
  48798. */
  48799. update(data: ArrayBufferView): void;
  48800. }
  48801. }
  48802. declare module BABYLON {
  48803. /**
  48804. * Creates a refraction texture used by refraction channel of the standard material.
  48805. * It is like a mirror but to see through a material.
  48806. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48807. */
  48808. export class RefractionTexture extends RenderTargetTexture {
  48809. /**
  48810. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48811. * 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.
  48812. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48813. */
  48814. refractionPlane: Plane;
  48815. /**
  48816. * Define how deep under the surface we should see.
  48817. */
  48818. depth: number;
  48819. /**
  48820. * Creates a refraction texture used by refraction channel of the standard material.
  48821. * It is like a mirror but to see through a material.
  48822. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48823. * @param name Define the texture name
  48824. * @param size Define the size of the underlying texture
  48825. * @param scene Define the scene the refraction belongs to
  48826. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48827. */
  48828. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48829. /**
  48830. * Clone the refraction texture.
  48831. * @returns the cloned texture
  48832. */
  48833. clone(): RefractionTexture;
  48834. /**
  48835. * Serialize the texture to a JSON representation you could use in Parse later on
  48836. * @returns the serialized JSON representation
  48837. */
  48838. serialize(): any;
  48839. }
  48840. }
  48841. declare module BABYLON {
  48842. /**
  48843. * Defines the options related to the creation of an HtmlElementTexture
  48844. */
  48845. export interface IHtmlElementTextureOptions {
  48846. /**
  48847. * Defines wether mip maps should be created or not.
  48848. */
  48849. generateMipMaps?: boolean;
  48850. /**
  48851. * Defines the sampling mode of the texture.
  48852. */
  48853. samplingMode?: number;
  48854. /**
  48855. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  48856. */
  48857. engine: Nullable<Engine>;
  48858. /**
  48859. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  48860. */
  48861. scene: Nullable<Scene>;
  48862. }
  48863. /**
  48864. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  48865. * To be as efficient as possible depending on your constraints nothing aside the first upload
  48866. * is automatically managed.
  48867. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  48868. * in your application.
  48869. *
  48870. * As the update is not automatic, you need to call them manually.
  48871. */
  48872. export class HtmlElementTexture extends BaseTexture {
  48873. /**
  48874. * The texture URL.
  48875. */
  48876. element: HTMLVideoElement | HTMLCanvasElement;
  48877. private static readonly DefaultOptions;
  48878. private _textureMatrix;
  48879. private _engine;
  48880. private _isVideo;
  48881. private _generateMipMaps;
  48882. private _samplingMode;
  48883. /**
  48884. * Instantiates a HtmlElementTexture from the following parameters.
  48885. *
  48886. * @param name Defines the name of the texture
  48887. * @param element Defines the video or canvas the texture is filled with
  48888. * @param options Defines the other none mandatory texture creation options
  48889. */
  48890. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  48891. private _createInternalTexture;
  48892. /**
  48893. * Returns the texture matrix used in most of the material.
  48894. */
  48895. getTextureMatrix(): Matrix;
  48896. /**
  48897. * Updates the content of the texture.
  48898. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  48899. */
  48900. update(invertY?: Nullable<boolean>): void;
  48901. }
  48902. }
  48903. declare module BABYLON {
  48904. /**
  48905. * Helper class to push actions to a pool of workers.
  48906. */
  48907. export class WorkerPool implements IDisposable {
  48908. private _workerInfos;
  48909. private _pendingActions;
  48910. /**
  48911. * Constructor
  48912. * @param workers Array of workers to use for actions
  48913. */
  48914. constructor(workers: Array<Worker>);
  48915. /**
  48916. * Terminates all workers and clears any pending actions.
  48917. */
  48918. dispose(): void;
  48919. /**
  48920. * Pushes an action to the worker pool. If all the workers are active, the action will be
  48921. * pended until a worker has completed its action.
  48922. * @param action The action to perform. Call onComplete when the action is complete.
  48923. */
  48924. push(action: (worker: Worker, onComplete: () => void) => void): void;
  48925. private _execute;
  48926. }
  48927. }
  48928. declare module BABYLON {
  48929. /**
  48930. * Configuration for Draco compression
  48931. */
  48932. export interface IDracoCompressionConfiguration {
  48933. /**
  48934. * Configuration for the decoder.
  48935. */
  48936. decoder?: {
  48937. /**
  48938. * The url to the WebAssembly module.
  48939. */
  48940. wasmUrl?: string;
  48941. /**
  48942. * The url to the WebAssembly binary.
  48943. */
  48944. wasmBinaryUrl?: string;
  48945. /**
  48946. * The url to the fallback JavaScript module.
  48947. */
  48948. fallbackUrl?: string;
  48949. };
  48950. }
  48951. /**
  48952. * Draco compression (https://google.github.io/draco/)
  48953. *
  48954. * This class wraps the Draco module.
  48955. *
  48956. * **Encoder**
  48957. *
  48958. * The encoder is not currently implemented.
  48959. *
  48960. * **Decoder**
  48961. *
  48962. * 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.
  48963. *
  48964. * To update the configuration, use the following code:
  48965. * ```javascript
  48966. * DracoCompression.Configuration = {
  48967. * decoder: {
  48968. * wasmUrl: "<url to the WebAssembly library>",
  48969. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48970. * fallbackUrl: "<url to the fallback JavaScript library>",
  48971. * }
  48972. * };
  48973. * ```
  48974. *
  48975. * 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.
  48976. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48977. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48978. *
  48979. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48980. * ```javascript
  48981. * var dracoCompression = new DracoCompression();
  48982. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48983. * [VertexBuffer.PositionKind]: 0
  48984. * });
  48985. * ```
  48986. *
  48987. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48988. */
  48989. export class DracoCompression implements IDisposable {
  48990. private _workerPoolPromise;
  48991. /**
  48992. * The configuration. Defaults to the following urls:
  48993. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48994. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48995. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48996. */
  48997. static Configuration: IDracoCompressionConfiguration;
  48998. /**
  48999. * Returns true if the decoder is available.
  49000. */
  49001. static readonly DecoderAvailable: boolean;
  49002. /**
  49003. * Default number of workers to create when creating the draco compression object.
  49004. */
  49005. static DefaultNumWorkers: number;
  49006. private static GetDefaultNumWorkers;
  49007. /**
  49008. * Constructor
  49009. * @param numWorkers The number of workers for async operations
  49010. */
  49011. constructor(numWorkers?: number);
  49012. /**
  49013. * Stop all async operations and release resources.
  49014. */
  49015. dispose(): void;
  49016. /**
  49017. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49018. * @returns a promise that resolves when ready
  49019. */
  49020. whenReadyAsync(): Promise<void>;
  49021. /**
  49022. * Decode Draco compressed mesh data to vertex data.
  49023. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49024. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49025. * @returns A promise that resolves with the decoded vertex data
  49026. */
  49027. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49028. [kind: string]: number;
  49029. }): Promise<VertexData>;
  49030. /**
  49031. * The worker function that gets converted to a blob url to pass into a worker.
  49032. */
  49033. private static _Worker;
  49034. private _loadDecoderWasmBinaryAsync;
  49035. }
  49036. }
  49037. declare module BABYLON {
  49038. /**
  49039. * Class for building Constructive Solid Geometry
  49040. */
  49041. export class CSG {
  49042. private polygons;
  49043. /**
  49044. * The world matrix
  49045. */
  49046. matrix: Matrix;
  49047. /**
  49048. * Stores the position
  49049. */
  49050. position: Vector3;
  49051. /**
  49052. * Stores the rotation
  49053. */
  49054. rotation: Vector3;
  49055. /**
  49056. * Stores the rotation quaternion
  49057. */
  49058. rotationQuaternion: Nullable<Quaternion>;
  49059. /**
  49060. * Stores the scaling vector
  49061. */
  49062. scaling: Vector3;
  49063. /**
  49064. * Convert the Mesh to CSG
  49065. * @param mesh The Mesh to convert to CSG
  49066. * @returns A new CSG from the Mesh
  49067. */
  49068. static FromMesh(mesh: Mesh): CSG;
  49069. /**
  49070. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49071. * @param polygons Polygons used to construct a CSG solid
  49072. */
  49073. private static FromPolygons;
  49074. /**
  49075. * Clones, or makes a deep copy, of the CSG
  49076. * @returns A new CSG
  49077. */
  49078. clone(): CSG;
  49079. /**
  49080. * Unions this CSG with another CSG
  49081. * @param csg The CSG to union against this CSG
  49082. * @returns The unioned CSG
  49083. */
  49084. union(csg: CSG): CSG;
  49085. /**
  49086. * Unions this CSG with another CSG in place
  49087. * @param csg The CSG to union against this CSG
  49088. */
  49089. unionInPlace(csg: CSG): void;
  49090. /**
  49091. * Subtracts this CSG with another CSG
  49092. * @param csg The CSG to subtract against this CSG
  49093. * @returns A new CSG
  49094. */
  49095. subtract(csg: CSG): CSG;
  49096. /**
  49097. * Subtracts this CSG with another CSG in place
  49098. * @param csg The CSG to subtact against this CSG
  49099. */
  49100. subtractInPlace(csg: CSG): void;
  49101. /**
  49102. * Intersect this CSG with another CSG
  49103. * @param csg The CSG to intersect against this CSG
  49104. * @returns A new CSG
  49105. */
  49106. intersect(csg: CSG): CSG;
  49107. /**
  49108. * Intersects this CSG with another CSG in place
  49109. * @param csg The CSG to intersect against this CSG
  49110. */
  49111. intersectInPlace(csg: CSG): void;
  49112. /**
  49113. * Return a new CSG solid with solid and empty space switched. This solid is
  49114. * not modified.
  49115. * @returns A new CSG solid with solid and empty space switched
  49116. */
  49117. inverse(): CSG;
  49118. /**
  49119. * Inverses the CSG in place
  49120. */
  49121. inverseInPlace(): void;
  49122. /**
  49123. * This is used to keep meshes transformations so they can be restored
  49124. * when we build back a Babylon Mesh
  49125. * NB : All CSG operations are performed in world coordinates
  49126. * @param csg The CSG to copy the transform attributes from
  49127. * @returns This CSG
  49128. */
  49129. copyTransformAttributes(csg: CSG): CSG;
  49130. /**
  49131. * Build Raw mesh from CSG
  49132. * Coordinates here are in world space
  49133. * @param name The name of the mesh geometry
  49134. * @param scene The Scene
  49135. * @param keepSubMeshes Specifies if the submeshes should be kept
  49136. * @returns A new Mesh
  49137. */
  49138. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49139. /**
  49140. * Build Mesh from CSG taking material and transforms into account
  49141. * @param name The name of the Mesh
  49142. * @param material The material of the Mesh
  49143. * @param scene The Scene
  49144. * @param keepSubMeshes Specifies if submeshes should be kept
  49145. * @returns The new Mesh
  49146. */
  49147. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49148. }
  49149. }
  49150. declare module BABYLON {
  49151. /**
  49152. * Class used to create a trail following a mesh
  49153. */
  49154. export class TrailMesh extends Mesh {
  49155. private _generator;
  49156. private _autoStart;
  49157. private _running;
  49158. private _diameter;
  49159. private _length;
  49160. private _sectionPolygonPointsCount;
  49161. private _sectionVectors;
  49162. private _sectionNormalVectors;
  49163. private _beforeRenderObserver;
  49164. /**
  49165. * @constructor
  49166. * @param name The value used by scene.getMeshByName() to do a lookup.
  49167. * @param generator The mesh to generate a trail.
  49168. * @param scene The scene to add this mesh to.
  49169. * @param diameter Diameter of trailing mesh. Default is 1.
  49170. * @param length Length of trailing mesh. Default is 60.
  49171. * @param autoStart Automatically start trailing mesh. Default true.
  49172. */
  49173. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49174. /**
  49175. * "TrailMesh"
  49176. * @returns "TrailMesh"
  49177. */
  49178. getClassName(): string;
  49179. private _createMesh;
  49180. /**
  49181. * Start trailing mesh.
  49182. */
  49183. start(): void;
  49184. /**
  49185. * Stop trailing mesh.
  49186. */
  49187. stop(): void;
  49188. /**
  49189. * Update trailing mesh geometry.
  49190. */
  49191. update(): void;
  49192. /**
  49193. * Returns a new TrailMesh object.
  49194. * @param name is a string, the name given to the new mesh
  49195. * @param newGenerator use new generator object for cloned trail mesh
  49196. * @returns a new mesh
  49197. */
  49198. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49199. /**
  49200. * Serializes this trail mesh
  49201. * @param serializationObject object to write serialization to
  49202. */
  49203. serialize(serializationObject: any): void;
  49204. /**
  49205. * Parses a serialized trail mesh
  49206. * @param parsedMesh the serialized mesh
  49207. * @param scene the scene to create the trail mesh in
  49208. * @returns the created trail mesh
  49209. */
  49210. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49211. }
  49212. }
  49213. declare module BABYLON {
  49214. /**
  49215. * Class containing static functions to help procedurally build meshes
  49216. */
  49217. export class TorusKnotBuilder {
  49218. /**
  49219. * Creates a torus knot mesh
  49220. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49221. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49222. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49223. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49225. * * 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
  49226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49227. * @param name defines the name of the mesh
  49228. * @param options defines the options used to create the mesh
  49229. * @param scene defines the hosting scene
  49230. * @returns the torus knot mesh
  49231. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49232. */
  49233. static CreateTorusKnot(name: string, options: {
  49234. radius?: number;
  49235. tube?: number;
  49236. radialSegments?: number;
  49237. tubularSegments?: number;
  49238. p?: number;
  49239. q?: number;
  49240. updatable?: boolean;
  49241. sideOrientation?: number;
  49242. frontUVs?: Vector4;
  49243. backUVs?: Vector4;
  49244. }, scene: any): Mesh;
  49245. }
  49246. }
  49247. declare module BABYLON {
  49248. /**
  49249. * Polygon
  49250. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49251. */
  49252. export class Polygon {
  49253. /**
  49254. * Creates a rectangle
  49255. * @param xmin bottom X coord
  49256. * @param ymin bottom Y coord
  49257. * @param xmax top X coord
  49258. * @param ymax top Y coord
  49259. * @returns points that make the resulting rectation
  49260. */
  49261. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49262. /**
  49263. * Creates a circle
  49264. * @param radius radius of circle
  49265. * @param cx scale in x
  49266. * @param cy scale in y
  49267. * @param numberOfSides number of sides that make up the circle
  49268. * @returns points that make the resulting circle
  49269. */
  49270. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49271. /**
  49272. * Creates a polygon from input string
  49273. * @param input Input polygon data
  49274. * @returns the parsed points
  49275. */
  49276. static Parse(input: string): Vector2[];
  49277. /**
  49278. * Starts building a polygon from x and y coordinates
  49279. * @param x x coordinate
  49280. * @param y y coordinate
  49281. * @returns the started path2
  49282. */
  49283. static StartingAt(x: number, y: number): Path2;
  49284. }
  49285. /**
  49286. * Builds a polygon
  49287. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49288. */
  49289. export class PolygonMeshBuilder {
  49290. private _points;
  49291. private _outlinepoints;
  49292. private _holes;
  49293. private _name;
  49294. private _scene;
  49295. private _epoints;
  49296. private _eholes;
  49297. private _addToepoint;
  49298. /**
  49299. * Babylon reference to the earcut plugin.
  49300. */
  49301. bjsEarcut: any;
  49302. /**
  49303. * Creates a PolygonMeshBuilder
  49304. * @param name name of the builder
  49305. * @param contours Path of the polygon
  49306. * @param scene scene to add to when creating the mesh
  49307. * @param earcutInjection can be used to inject your own earcut reference
  49308. */
  49309. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  49310. /**
  49311. * Adds a whole within the polygon
  49312. * @param hole Array of points defining the hole
  49313. * @returns this
  49314. */
  49315. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49316. /**
  49317. * Creates the polygon
  49318. * @param updatable If the mesh should be updatable
  49319. * @param depth The depth of the mesh created
  49320. * @returns the created mesh
  49321. */
  49322. build(updatable?: boolean, depth?: number): Mesh;
  49323. /**
  49324. * Creates the polygon
  49325. * @param depth The depth of the mesh created
  49326. * @returns the created VertexData
  49327. */
  49328. buildVertexData(depth?: number): VertexData;
  49329. /**
  49330. * Adds a side to the polygon
  49331. * @param positions points that make the polygon
  49332. * @param normals normals of the polygon
  49333. * @param uvs uvs of the polygon
  49334. * @param indices indices of the polygon
  49335. * @param bounds bounds of the polygon
  49336. * @param points points of the polygon
  49337. * @param depth depth of the polygon
  49338. * @param flip flip of the polygon
  49339. */
  49340. private addSide;
  49341. }
  49342. }
  49343. declare module BABYLON {
  49344. /**
  49345. * Class containing static functions to help procedurally build meshes
  49346. */
  49347. export class PolygonBuilder {
  49348. /**
  49349. * Creates a polygon mesh
  49350. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49351. * * 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
  49352. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49354. * * 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)
  49355. * * Remember you can only change the shape positions, not their number when updating a polygon
  49356. * @param name defines the name of the mesh
  49357. * @param options defines the options used to create the mesh
  49358. * @param scene defines the hosting scene
  49359. * @param earcutInjection can be used to inject your own earcut reference
  49360. * @returns the polygon mesh
  49361. */
  49362. static CreatePolygon(name: string, options: {
  49363. shape: Vector3[];
  49364. holes?: Vector3[][];
  49365. depth?: number;
  49366. faceUV?: Vector4[];
  49367. faceColors?: Color4[];
  49368. updatable?: boolean;
  49369. sideOrientation?: number;
  49370. frontUVs?: Vector4;
  49371. backUVs?: Vector4;
  49372. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49373. /**
  49374. * Creates an extruded polygon mesh, with depth in the Y direction.
  49375. * * 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)
  49376. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49377. * @param name defines the name of the mesh
  49378. * @param options defines the options used to create the mesh
  49379. * @param scene defines the hosting scene
  49380. * @param earcutInjection can be used to inject your own earcut reference
  49381. * @returns the polygon mesh
  49382. */
  49383. static ExtrudePolygon(name: string, options: {
  49384. shape: Vector3[];
  49385. holes?: Vector3[][];
  49386. depth?: number;
  49387. faceUV?: Vector4[];
  49388. faceColors?: Color4[];
  49389. updatable?: boolean;
  49390. sideOrientation?: number;
  49391. frontUVs?: Vector4;
  49392. backUVs?: Vector4;
  49393. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49394. }
  49395. }
  49396. declare module BABYLON {
  49397. /**
  49398. * Class containing static functions to help procedurally build meshes
  49399. */
  49400. export class LatheBuilder {
  49401. /**
  49402. * Creates lathe mesh.
  49403. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49404. * * 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
  49405. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49406. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49407. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49408. * * 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
  49409. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49410. * * 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
  49411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49412. * * 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
  49413. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49415. * @param name defines the name of the mesh
  49416. * @param options defines the options used to create the mesh
  49417. * @param scene defines the hosting scene
  49418. * @returns the lathe mesh
  49419. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49420. */
  49421. static CreateLathe(name: string, options: {
  49422. shape: Vector3[];
  49423. radius?: number;
  49424. tessellation?: number;
  49425. clip?: number;
  49426. arc?: number;
  49427. closed?: boolean;
  49428. updatable?: boolean;
  49429. sideOrientation?: number;
  49430. frontUVs?: Vector4;
  49431. backUVs?: Vector4;
  49432. cap?: number;
  49433. invertUV?: boolean;
  49434. }, scene?: Nullable<Scene>): Mesh;
  49435. }
  49436. }
  49437. declare module BABYLON {
  49438. /**
  49439. * Class containing static functions to help procedurally build meshes
  49440. */
  49441. export class TubeBuilder {
  49442. /**
  49443. * Creates a tube mesh.
  49444. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49445. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49446. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49447. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49448. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49449. * * 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)
  49450. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49451. * * 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
  49452. * * 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
  49453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49454. * * 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
  49455. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49457. * @param name defines the name of the mesh
  49458. * @param options defines the options used to create the mesh
  49459. * @param scene defines the hosting scene
  49460. * @returns the tube mesh
  49461. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49462. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49463. */
  49464. static CreateTube(name: string, options: {
  49465. path: Vector3[];
  49466. radius?: number;
  49467. tessellation?: number;
  49468. radiusFunction?: {
  49469. (i: number, distance: number): number;
  49470. };
  49471. cap?: number;
  49472. arc?: number;
  49473. updatable?: boolean;
  49474. sideOrientation?: number;
  49475. frontUVs?: Vector4;
  49476. backUVs?: Vector4;
  49477. instance?: Mesh;
  49478. invertUV?: boolean;
  49479. }, scene?: Nullable<Scene>): Mesh;
  49480. }
  49481. }
  49482. declare module BABYLON {
  49483. /**
  49484. * Class containing static functions to help procedurally build meshes
  49485. */
  49486. export class IcoSphereBuilder {
  49487. /**
  49488. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49489. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49490. * * 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`)
  49491. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49492. * * 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
  49493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49494. * * 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
  49495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49496. * @param name defines the name of the mesh
  49497. * @param options defines the options used to create the mesh
  49498. * @param scene defines the hosting scene
  49499. * @returns the icosahedron mesh
  49500. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49501. */
  49502. static CreateIcoSphere(name: string, options: {
  49503. radius?: number;
  49504. radiusX?: number;
  49505. radiusY?: number;
  49506. radiusZ?: number;
  49507. flat?: boolean;
  49508. subdivisions?: number;
  49509. sideOrientation?: number;
  49510. frontUVs?: Vector4;
  49511. backUVs?: Vector4;
  49512. updatable?: boolean;
  49513. }, scene?: Nullable<Scene>): Mesh;
  49514. }
  49515. }
  49516. declare module BABYLON {
  49517. /**
  49518. * Class containing static functions to help procedurally build meshes
  49519. */
  49520. export class DecalBuilder {
  49521. /**
  49522. * Creates a decal mesh.
  49523. * 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
  49524. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49525. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49526. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49527. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49528. * @param name defines the name of the mesh
  49529. * @param sourceMesh defines the mesh where the decal must be applied
  49530. * @param options defines the options used to create the mesh
  49531. * @param scene defines the hosting scene
  49532. * @returns the decal mesh
  49533. * @see https://doc.babylonjs.com/how_to/decals
  49534. */
  49535. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49536. position?: Vector3;
  49537. normal?: Vector3;
  49538. size?: Vector3;
  49539. angle?: number;
  49540. }): Mesh;
  49541. }
  49542. }
  49543. declare module BABYLON {
  49544. /**
  49545. * Class containing static functions to help procedurally build meshes
  49546. */
  49547. export class MeshBuilder {
  49548. /**
  49549. * Creates a box mesh
  49550. * * The parameter `size` sets the size (float) of each box side (default 1)
  49551. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49552. * * 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)
  49553. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49555. * * 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
  49556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49557. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49558. * @param name defines the name of the mesh
  49559. * @param options defines the options used to create the mesh
  49560. * @param scene defines the hosting scene
  49561. * @returns the box mesh
  49562. */
  49563. static CreateBox(name: string, options: {
  49564. size?: number;
  49565. width?: number;
  49566. height?: number;
  49567. depth?: number;
  49568. faceUV?: Vector4[];
  49569. faceColors?: Color4[];
  49570. sideOrientation?: number;
  49571. frontUVs?: Vector4;
  49572. backUVs?: Vector4;
  49573. updatable?: boolean;
  49574. }, scene?: Nullable<Scene>): Mesh;
  49575. /**
  49576. * Creates a sphere mesh
  49577. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49578. * * 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`)
  49579. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49580. * * 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
  49581. * * 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)
  49582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49583. * * 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
  49584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49585. * @param name defines the name of the mesh
  49586. * @param options defines the options used to create the mesh
  49587. * @param scene defines the hosting scene
  49588. * @returns the sphere mesh
  49589. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49590. */
  49591. static CreateSphere(name: string, options: {
  49592. segments?: number;
  49593. diameter?: number;
  49594. diameterX?: number;
  49595. diameterY?: number;
  49596. diameterZ?: number;
  49597. arc?: number;
  49598. slice?: number;
  49599. sideOrientation?: number;
  49600. frontUVs?: Vector4;
  49601. backUVs?: Vector4;
  49602. updatable?: boolean;
  49603. }, scene?: Nullable<Scene>): Mesh;
  49604. /**
  49605. * Creates a plane polygonal mesh. By default, this is a disc
  49606. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49607. * * 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
  49608. * * 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
  49609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49610. * * 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
  49611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49612. * @param name defines the name of the mesh
  49613. * @param options defines the options used to create the mesh
  49614. * @param scene defines the hosting scene
  49615. * @returns the plane polygonal mesh
  49616. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49617. */
  49618. static CreateDisc(name: string, options: {
  49619. radius?: number;
  49620. tessellation?: number;
  49621. arc?: number;
  49622. updatable?: boolean;
  49623. sideOrientation?: number;
  49624. frontUVs?: Vector4;
  49625. backUVs?: Vector4;
  49626. }, scene?: Nullable<Scene>): Mesh;
  49627. /**
  49628. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49629. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49630. * * 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`)
  49631. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49632. * * 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
  49633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49634. * * 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
  49635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49636. * @param name defines the name of the mesh
  49637. * @param options defines the options used to create the mesh
  49638. * @param scene defines the hosting scene
  49639. * @returns the icosahedron mesh
  49640. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49641. */
  49642. static CreateIcoSphere(name: string, options: {
  49643. radius?: number;
  49644. radiusX?: number;
  49645. radiusY?: number;
  49646. radiusZ?: number;
  49647. flat?: boolean;
  49648. subdivisions?: number;
  49649. sideOrientation?: number;
  49650. frontUVs?: Vector4;
  49651. backUVs?: Vector4;
  49652. updatable?: boolean;
  49653. }, scene?: Nullable<Scene>): Mesh;
  49654. /**
  49655. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49656. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49657. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49658. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49659. * * 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
  49660. * * 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
  49661. * * 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
  49662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49663. * * 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
  49664. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49665. * * 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
  49666. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49667. * * 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
  49668. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49670. * @param name defines the name of the mesh
  49671. * @param options defines the options used to create the mesh
  49672. * @param scene defines the hosting scene
  49673. * @returns the ribbon mesh
  49674. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49675. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49676. */
  49677. static CreateRibbon(name: string, options: {
  49678. pathArray: Vector3[][];
  49679. closeArray?: boolean;
  49680. closePath?: boolean;
  49681. offset?: number;
  49682. updatable?: boolean;
  49683. sideOrientation?: number;
  49684. frontUVs?: Vector4;
  49685. backUVs?: Vector4;
  49686. instance?: Mesh;
  49687. invertUV?: boolean;
  49688. uvs?: Vector2[];
  49689. colors?: Color4[];
  49690. }, scene?: Nullable<Scene>): Mesh;
  49691. /**
  49692. * Creates a cylinder or a cone mesh
  49693. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49694. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49695. * * 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.
  49696. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49697. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49698. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49699. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49700. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49701. * * 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).
  49702. * * 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
  49703. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49704. * * 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
  49705. * * 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.
  49706. * * If `enclose` is false, a ring surface is one element.
  49707. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49708. * * 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
  49709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49710. * * 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
  49711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49712. * @param name defines the name of the mesh
  49713. * @param options defines the options used to create the mesh
  49714. * @param scene defines the hosting scene
  49715. * @returns the cylinder mesh
  49716. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49717. */
  49718. static CreateCylinder(name: string, options: {
  49719. height?: number;
  49720. diameterTop?: number;
  49721. diameterBottom?: number;
  49722. diameter?: number;
  49723. tessellation?: number;
  49724. subdivisions?: number;
  49725. arc?: number;
  49726. faceColors?: Color4[];
  49727. faceUV?: Vector4[];
  49728. updatable?: boolean;
  49729. hasRings?: boolean;
  49730. enclose?: boolean;
  49731. sideOrientation?: number;
  49732. frontUVs?: Vector4;
  49733. backUVs?: Vector4;
  49734. }, scene?: Nullable<Scene>): Mesh;
  49735. /**
  49736. * Creates a torus mesh
  49737. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49738. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49739. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49741. * * 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
  49742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49743. * @param name defines the name of the mesh
  49744. * @param options defines the options used to create the mesh
  49745. * @param scene defines the hosting scene
  49746. * @returns the torus mesh
  49747. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49748. */
  49749. static CreateTorus(name: string, options: {
  49750. diameter?: number;
  49751. thickness?: number;
  49752. tessellation?: number;
  49753. updatable?: boolean;
  49754. sideOrientation?: number;
  49755. frontUVs?: Vector4;
  49756. backUVs?: Vector4;
  49757. }, scene?: Nullable<Scene>): Mesh;
  49758. /**
  49759. * Creates a torus knot mesh
  49760. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49761. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49762. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49763. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49765. * * 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
  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 torus knot mesh
  49771. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49772. */
  49773. static CreateTorusKnot(name: string, options: {
  49774. radius?: number;
  49775. tube?: number;
  49776. radialSegments?: number;
  49777. tubularSegments?: number;
  49778. p?: number;
  49779. q?: number;
  49780. updatable?: boolean;
  49781. sideOrientation?: number;
  49782. frontUVs?: Vector4;
  49783. backUVs?: Vector4;
  49784. }, scene?: Nullable<Scene>): Mesh;
  49785. /**
  49786. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49787. * * 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
  49788. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49789. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49790. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49791. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49792. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49793. * * 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
  49794. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49796. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49797. * @param name defines the name of the new line system
  49798. * @param options defines the options used to create the line system
  49799. * @param scene defines the hosting scene
  49800. * @returns a new line system mesh
  49801. */
  49802. static CreateLineSystem(name: string, options: {
  49803. lines: Vector3[][];
  49804. updatable?: boolean;
  49805. instance?: Nullable<LinesMesh>;
  49806. colors?: Nullable<Color4[][]>;
  49807. useVertexAlpha?: boolean;
  49808. }, scene: Nullable<Scene>): LinesMesh;
  49809. /**
  49810. * Creates a line mesh
  49811. * 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
  49812. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49813. * * The parameter `points` is an array successive Vector3
  49814. * * 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
  49815. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49816. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49817. * * When updating an instance, remember that only point positions can change, not the number of points
  49818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49820. * @param name defines the name of the new line system
  49821. * @param options defines the options used to create the line system
  49822. * @param scene defines the hosting scene
  49823. * @returns a new line mesh
  49824. */
  49825. static CreateLines(name: string, options: {
  49826. points: Vector3[];
  49827. updatable?: boolean;
  49828. instance?: Nullable<LinesMesh>;
  49829. colors?: Color4[];
  49830. useVertexAlpha?: boolean;
  49831. }, scene?: Nullable<Scene>): LinesMesh;
  49832. /**
  49833. * Creates a dashed line mesh
  49834. * * 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
  49835. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49836. * * The parameter `points` is an array successive Vector3
  49837. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49838. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49839. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49840. * * 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
  49841. * * When updating an instance, remember that only point positions can change, not the number of points
  49842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49843. * @param name defines the name of the mesh
  49844. * @param options defines the options used to create the mesh
  49845. * @param scene defines the hosting scene
  49846. * @returns the dashed line mesh
  49847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49848. */
  49849. static CreateDashedLines(name: string, options: {
  49850. points: Vector3[];
  49851. dashSize?: number;
  49852. gapSize?: number;
  49853. dashNb?: number;
  49854. updatable?: boolean;
  49855. instance?: LinesMesh;
  49856. }, scene?: Nullable<Scene>): LinesMesh;
  49857. /**
  49858. * 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.
  49859. * * 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.
  49860. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49861. * * 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.
  49862. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49863. * * 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
  49864. * * 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
  49865. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49867. * * 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
  49868. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49870. * @param name defines the name of the mesh
  49871. * @param options defines the options used to create the mesh
  49872. * @param scene defines the hosting scene
  49873. * @returns the extruded shape mesh
  49874. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49876. */
  49877. static ExtrudeShape(name: string, options: {
  49878. shape: Vector3[];
  49879. path: Vector3[];
  49880. scale?: number;
  49881. rotation?: number;
  49882. cap?: number;
  49883. updatable?: boolean;
  49884. sideOrientation?: number;
  49885. frontUVs?: Vector4;
  49886. backUVs?: Vector4;
  49887. instance?: Mesh;
  49888. invertUV?: boolean;
  49889. }, scene?: Nullable<Scene>): Mesh;
  49890. /**
  49891. * Creates an custom extruded shape mesh.
  49892. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49893. * * 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.
  49894. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49895. * * 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
  49896. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49897. * * 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
  49898. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49899. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49900. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49901. * * 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
  49902. * * 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
  49903. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49905. * * 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
  49906. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49908. * @param name defines the name of the mesh
  49909. * @param options defines the options used to create the mesh
  49910. * @param scene defines the hosting scene
  49911. * @returns the custom extruded shape mesh
  49912. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49913. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49915. */
  49916. static ExtrudeShapeCustom(name: string, options: {
  49917. shape: Vector3[];
  49918. path: Vector3[];
  49919. scaleFunction?: any;
  49920. rotationFunction?: any;
  49921. ribbonCloseArray?: boolean;
  49922. ribbonClosePath?: boolean;
  49923. cap?: number;
  49924. updatable?: boolean;
  49925. sideOrientation?: number;
  49926. frontUVs?: Vector4;
  49927. backUVs?: Vector4;
  49928. instance?: Mesh;
  49929. invertUV?: boolean;
  49930. }, scene?: Nullable<Scene>): Mesh;
  49931. /**
  49932. * Creates lathe mesh.
  49933. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49934. * * 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
  49935. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49936. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49937. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49938. * * 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
  49939. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49940. * * 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
  49941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49942. * * 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
  49943. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49945. * @param name defines the name of the mesh
  49946. * @param options defines the options used to create the mesh
  49947. * @param scene defines the hosting scene
  49948. * @returns the lathe mesh
  49949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49950. */
  49951. static CreateLathe(name: string, options: {
  49952. shape: Vector3[];
  49953. radius?: number;
  49954. tessellation?: number;
  49955. clip?: number;
  49956. arc?: number;
  49957. closed?: boolean;
  49958. updatable?: boolean;
  49959. sideOrientation?: number;
  49960. frontUVs?: Vector4;
  49961. backUVs?: Vector4;
  49962. cap?: number;
  49963. invertUV?: boolean;
  49964. }, scene?: Nullable<Scene>): Mesh;
  49965. /**
  49966. * Creates a plane mesh
  49967. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49968. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49969. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49971. * * 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
  49972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49973. * @param name defines the name of the mesh
  49974. * @param options defines the options used to create the mesh
  49975. * @param scene defines the hosting scene
  49976. * @returns the plane mesh
  49977. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49978. */
  49979. static CreatePlane(name: string, options: {
  49980. size?: number;
  49981. width?: number;
  49982. height?: number;
  49983. sideOrientation?: number;
  49984. frontUVs?: Vector4;
  49985. backUVs?: Vector4;
  49986. updatable?: boolean;
  49987. sourcePlane?: Plane;
  49988. }, scene?: Nullable<Scene>): Mesh;
  49989. /**
  49990. * Creates a ground mesh
  49991. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49992. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49994. * @param name defines the name of the mesh
  49995. * @param options defines the options used to create the mesh
  49996. * @param scene defines the hosting scene
  49997. * @returns the ground mesh
  49998. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49999. */
  50000. static CreateGround(name: string, options: {
  50001. width?: number;
  50002. height?: number;
  50003. subdivisions?: number;
  50004. subdivisionsX?: number;
  50005. subdivisionsY?: number;
  50006. updatable?: boolean;
  50007. }, scene?: Nullable<Scene>): Mesh;
  50008. /**
  50009. * Creates a tiled ground mesh
  50010. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50011. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50012. * * 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
  50013. * * 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
  50014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50015. * @param name defines the name of the mesh
  50016. * @param options defines the options used to create the mesh
  50017. * @param scene defines the hosting scene
  50018. * @returns the tiled ground mesh
  50019. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50020. */
  50021. static CreateTiledGround(name: string, options: {
  50022. xmin: number;
  50023. zmin: number;
  50024. xmax: number;
  50025. zmax: number;
  50026. subdivisions?: {
  50027. w: number;
  50028. h: number;
  50029. };
  50030. precision?: {
  50031. w: number;
  50032. h: number;
  50033. };
  50034. updatable?: boolean;
  50035. }, scene?: Nullable<Scene>): Mesh;
  50036. /**
  50037. * Creates a ground mesh from a height map
  50038. * * The parameter `url` sets the URL of the height map image resource.
  50039. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50040. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50041. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50042. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50043. * * 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.
  50044. * * 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).
  50045. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50047. * @param name defines the name of the mesh
  50048. * @param url defines the url to the height map
  50049. * @param options defines the options used to create the mesh
  50050. * @param scene defines the hosting scene
  50051. * @returns the ground mesh
  50052. * @see https://doc.babylonjs.com/babylon101/height_map
  50053. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50054. */
  50055. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50056. width?: number;
  50057. height?: number;
  50058. subdivisions?: number;
  50059. minHeight?: number;
  50060. maxHeight?: number;
  50061. colorFilter?: Color3;
  50062. alphaFilter?: number;
  50063. updatable?: boolean;
  50064. onReady?: (mesh: GroundMesh) => void;
  50065. }, scene?: Nullable<Scene>): GroundMesh;
  50066. /**
  50067. * Creates a polygon mesh
  50068. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50069. * * 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
  50070. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50072. * * 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)
  50073. * * Remember you can only change the shape positions, not their number when updating a polygon
  50074. * @param name defines the name of the mesh
  50075. * @param options defines the options used to create the mesh
  50076. * @param scene defines the hosting scene
  50077. * @param earcutInjection can be used to inject your own earcut reference
  50078. * @returns the polygon mesh
  50079. */
  50080. static CreatePolygon(name: string, options: {
  50081. shape: Vector3[];
  50082. holes?: Vector3[][];
  50083. depth?: number;
  50084. faceUV?: Vector4[];
  50085. faceColors?: Color4[];
  50086. updatable?: boolean;
  50087. sideOrientation?: number;
  50088. frontUVs?: Vector4;
  50089. backUVs?: Vector4;
  50090. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50091. /**
  50092. * Creates an extruded polygon mesh, with depth in the Y direction.
  50093. * * 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)
  50094. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50095. * @param name defines the name of the mesh
  50096. * @param options defines the options used to create the mesh
  50097. * @param scene defines the hosting scene
  50098. * @param earcutInjection can be used to inject your own earcut reference
  50099. * @returns the polygon mesh
  50100. */
  50101. static ExtrudePolygon(name: string, options: {
  50102. shape: Vector3[];
  50103. holes?: Vector3[][];
  50104. depth?: number;
  50105. faceUV?: Vector4[];
  50106. faceColors?: Color4[];
  50107. updatable?: boolean;
  50108. sideOrientation?: number;
  50109. frontUVs?: Vector4;
  50110. backUVs?: Vector4;
  50111. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50112. /**
  50113. * Creates a tube mesh.
  50114. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50115. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50116. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50117. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50118. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50119. * * 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)
  50120. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50121. * * 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
  50122. * * 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
  50123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50124. * * 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
  50125. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50127. * @param name defines the name of the mesh
  50128. * @param options defines the options used to create the mesh
  50129. * @param scene defines the hosting scene
  50130. * @returns the tube mesh
  50131. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50132. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50133. */
  50134. static CreateTube(name: string, options: {
  50135. path: Vector3[];
  50136. radius?: number;
  50137. tessellation?: number;
  50138. radiusFunction?: {
  50139. (i: number, distance: number): number;
  50140. };
  50141. cap?: number;
  50142. arc?: number;
  50143. updatable?: boolean;
  50144. sideOrientation?: number;
  50145. frontUVs?: Vector4;
  50146. backUVs?: Vector4;
  50147. instance?: Mesh;
  50148. invertUV?: boolean;
  50149. }, scene?: Nullable<Scene>): Mesh;
  50150. /**
  50151. * Creates a polyhedron mesh
  50152. * * 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
  50153. * * The parameter `size` (positive float, default 1) sets the polygon size
  50154. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50155. * * 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`
  50156. * * 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
  50157. * * 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)`)
  50158. * * 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
  50159. * * 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
  50160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50161. * * 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
  50162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50163. * @param name defines the name of the mesh
  50164. * @param options defines the options used to create the mesh
  50165. * @param scene defines the hosting scene
  50166. * @returns the polyhedron mesh
  50167. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50168. */
  50169. static CreatePolyhedron(name: string, options: {
  50170. type?: number;
  50171. size?: number;
  50172. sizeX?: number;
  50173. sizeY?: number;
  50174. sizeZ?: number;
  50175. custom?: any;
  50176. faceUV?: Vector4[];
  50177. faceColors?: Color4[];
  50178. flat?: boolean;
  50179. updatable?: boolean;
  50180. sideOrientation?: number;
  50181. frontUVs?: Vector4;
  50182. backUVs?: Vector4;
  50183. }, scene?: Nullable<Scene>): Mesh;
  50184. /**
  50185. * Creates a decal mesh.
  50186. * 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
  50187. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50188. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50189. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50190. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50191. * @param name defines the name of the mesh
  50192. * @param sourceMesh defines the mesh where the decal must be applied
  50193. * @param options defines the options used to create the mesh
  50194. * @param scene defines the hosting scene
  50195. * @returns the decal mesh
  50196. * @see https://doc.babylonjs.com/how_to/decals
  50197. */
  50198. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50199. position?: Vector3;
  50200. normal?: Vector3;
  50201. size?: Vector3;
  50202. angle?: number;
  50203. }): Mesh;
  50204. }
  50205. }
  50206. declare module BABYLON {
  50207. /**
  50208. * A simplifier interface for future simplification implementations
  50209. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50210. */
  50211. export interface ISimplifier {
  50212. /**
  50213. * Simplification of a given mesh according to the given settings.
  50214. * Since this requires computation, it is assumed that the function runs async.
  50215. * @param settings The settings of the simplification, including quality and distance
  50216. * @param successCallback A callback that will be called after the mesh was simplified.
  50217. * @param errorCallback in case of an error, this callback will be called. optional.
  50218. */
  50219. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50220. }
  50221. /**
  50222. * Expected simplification settings.
  50223. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50224. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50225. */
  50226. export interface ISimplificationSettings {
  50227. /**
  50228. * Gets or sets the expected quality
  50229. */
  50230. quality: number;
  50231. /**
  50232. * Gets or sets the distance when this optimized version should be used
  50233. */
  50234. distance: number;
  50235. /**
  50236. * Gets an already optimized mesh
  50237. */
  50238. optimizeMesh?: boolean;
  50239. }
  50240. /**
  50241. * Class used to specify simplification options
  50242. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50243. */
  50244. export class SimplificationSettings implements ISimplificationSettings {
  50245. /** expected quality */
  50246. quality: number;
  50247. /** distance when this optimized version should be used */
  50248. distance: number;
  50249. /** already optimized mesh */
  50250. optimizeMesh?: boolean | undefined;
  50251. /**
  50252. * Creates a SimplificationSettings
  50253. * @param quality expected quality
  50254. * @param distance distance when this optimized version should be used
  50255. * @param optimizeMesh already optimized mesh
  50256. */
  50257. constructor(
  50258. /** expected quality */
  50259. quality: number,
  50260. /** distance when this optimized version should be used */
  50261. distance: number,
  50262. /** already optimized mesh */
  50263. optimizeMesh?: boolean | undefined);
  50264. }
  50265. /**
  50266. * Interface used to define a simplification task
  50267. */
  50268. export interface ISimplificationTask {
  50269. /**
  50270. * Array of settings
  50271. */
  50272. settings: Array<ISimplificationSettings>;
  50273. /**
  50274. * Simplification type
  50275. */
  50276. simplificationType: SimplificationType;
  50277. /**
  50278. * Mesh to simplify
  50279. */
  50280. mesh: Mesh;
  50281. /**
  50282. * Callback called on success
  50283. */
  50284. successCallback?: () => void;
  50285. /**
  50286. * Defines if parallel processing can be used
  50287. */
  50288. parallelProcessing: boolean;
  50289. }
  50290. /**
  50291. * Queue used to order the simplification tasks
  50292. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50293. */
  50294. export class SimplificationQueue {
  50295. private _simplificationArray;
  50296. /**
  50297. * Gets a boolean indicating that the process is still running
  50298. */
  50299. running: boolean;
  50300. /**
  50301. * Creates a new queue
  50302. */
  50303. constructor();
  50304. /**
  50305. * Adds a new simplification task
  50306. * @param task defines a task to add
  50307. */
  50308. addTask(task: ISimplificationTask): void;
  50309. /**
  50310. * Execute next task
  50311. */
  50312. executeNext(): void;
  50313. /**
  50314. * Execute a simplification task
  50315. * @param task defines the task to run
  50316. */
  50317. runSimplification(task: ISimplificationTask): void;
  50318. private getSimplifier;
  50319. }
  50320. /**
  50321. * The implemented types of simplification
  50322. * At the moment only Quadratic Error Decimation is implemented
  50323. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50324. */
  50325. export enum SimplificationType {
  50326. /** Quadratic error decimation */
  50327. QUADRATIC = 0
  50328. }
  50329. }
  50330. declare module BABYLON {
  50331. interface Scene {
  50332. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  50333. /**
  50334. * Gets or sets the simplification queue attached to the scene
  50335. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50336. */
  50337. simplificationQueue: SimplificationQueue;
  50338. }
  50339. interface Mesh {
  50340. /**
  50341. * Simplify the mesh according to the given array of settings.
  50342. * Function will return immediately and will simplify async
  50343. * @param settings a collection of simplification settings
  50344. * @param parallelProcessing should all levels calculate parallel or one after the other
  50345. * @param simplificationType the type of simplification to run
  50346. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50347. * @returns the current mesh
  50348. */
  50349. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50350. }
  50351. /**
  50352. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50353. * created in a scene
  50354. */
  50355. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50356. /**
  50357. * The component name helpfull to identify the component in the list of scene components.
  50358. */
  50359. readonly name: string;
  50360. /**
  50361. * The scene the component belongs to.
  50362. */
  50363. scene: Scene;
  50364. /**
  50365. * Creates a new instance of the component for the given scene
  50366. * @param scene Defines the scene to register the component in
  50367. */
  50368. constructor(scene: Scene);
  50369. /**
  50370. * Registers the component in a given scene
  50371. */
  50372. register(): void;
  50373. /**
  50374. * Rebuilds the elements related to this component in case of
  50375. * context lost for instance.
  50376. */
  50377. rebuild(): void;
  50378. /**
  50379. * Disposes the component and the associated ressources
  50380. */
  50381. dispose(): void;
  50382. private _beforeCameraUpdate;
  50383. }
  50384. }
  50385. declare module BABYLON {
  50386. /**
  50387. * Class used to enable access to IndexedDB
  50388. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50389. */
  50390. export class Database implements IOfflineProvider {
  50391. private _callbackManifestChecked;
  50392. private _currentSceneUrl;
  50393. private _db;
  50394. private _enableSceneOffline;
  50395. private _enableTexturesOffline;
  50396. private _manifestVersionFound;
  50397. private _mustUpdateRessources;
  50398. private _hasReachedQuota;
  50399. private _isSupported;
  50400. private _idbFactory;
  50401. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50402. private static IsUASupportingBlobStorage;
  50403. /**
  50404. * Gets a boolean indicating if Database storate is enabled (off by default)
  50405. */
  50406. static IDBStorageEnabled: boolean;
  50407. /**
  50408. * Gets a boolean indicating if scene must be saved in the database
  50409. */
  50410. readonly enableSceneOffline: boolean;
  50411. /**
  50412. * Gets a boolean indicating if textures must be saved in the database
  50413. */
  50414. readonly enableTexturesOffline: boolean;
  50415. /**
  50416. * Creates a new Database
  50417. * @param urlToScene defines the url to load the scene
  50418. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50419. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50420. */
  50421. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50422. private static _ParseURL;
  50423. private static _ReturnFullUrlLocation;
  50424. private _checkManifestFile;
  50425. /**
  50426. * Open the database and make it available
  50427. * @param successCallback defines the callback to call on success
  50428. * @param errorCallback defines the callback to call on error
  50429. */
  50430. open(successCallback: () => void, errorCallback: () => void): void;
  50431. /**
  50432. * Loads an image from the database
  50433. * @param url defines the url to load from
  50434. * @param image defines the target DOM image
  50435. */
  50436. loadImage(url: string, image: HTMLImageElement): void;
  50437. private _loadImageFromDBAsync;
  50438. private _saveImageIntoDBAsync;
  50439. private _checkVersionFromDB;
  50440. private _loadVersionFromDBAsync;
  50441. private _saveVersionIntoDBAsync;
  50442. /**
  50443. * Loads a file from database
  50444. * @param url defines the URL to load from
  50445. * @param sceneLoaded defines a callback to call on success
  50446. * @param progressCallBack defines a callback to call when progress changed
  50447. * @param errorCallback defines a callback to call on error
  50448. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50449. */
  50450. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50451. private _loadFileAsync;
  50452. private _saveFileAsync;
  50453. /**
  50454. * Validates if xhr data is correct
  50455. * @param xhr defines the request to validate
  50456. * @param dataType defines the expected data type
  50457. * @returns true if data is correct
  50458. */
  50459. private static _ValidateXHRData;
  50460. }
  50461. }
  50462. declare module BABYLON {
  50463. /** @hidden */
  50464. export var gpuUpdateParticlesPixelShader: {
  50465. name: string;
  50466. shader: string;
  50467. };
  50468. }
  50469. declare module BABYLON {
  50470. /** @hidden */
  50471. export var gpuUpdateParticlesVertexShader: {
  50472. name: string;
  50473. shader: string;
  50474. };
  50475. }
  50476. declare module BABYLON {
  50477. /** @hidden */
  50478. export var clipPlaneFragmentDeclaration2: {
  50479. name: string;
  50480. shader: string;
  50481. };
  50482. }
  50483. declare module BABYLON {
  50484. /** @hidden */
  50485. export var gpuRenderParticlesPixelShader: {
  50486. name: string;
  50487. shader: string;
  50488. };
  50489. }
  50490. declare module BABYLON {
  50491. /** @hidden */
  50492. export var clipPlaneVertexDeclaration2: {
  50493. name: string;
  50494. shader: string;
  50495. };
  50496. }
  50497. declare module BABYLON {
  50498. /** @hidden */
  50499. export var gpuRenderParticlesVertexShader: {
  50500. name: string;
  50501. shader: string;
  50502. };
  50503. }
  50504. declare module BABYLON {
  50505. /**
  50506. * This represents a GPU particle system in Babylon
  50507. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50508. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50509. */
  50510. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50511. /**
  50512. * The layer mask we are rendering the particles through.
  50513. */
  50514. layerMask: number;
  50515. private _capacity;
  50516. private _activeCount;
  50517. private _currentActiveCount;
  50518. private _accumulatedCount;
  50519. private _renderEffect;
  50520. private _updateEffect;
  50521. private _buffer0;
  50522. private _buffer1;
  50523. private _spriteBuffer;
  50524. private _updateVAO;
  50525. private _renderVAO;
  50526. private _targetIndex;
  50527. private _sourceBuffer;
  50528. private _targetBuffer;
  50529. private _engine;
  50530. private _currentRenderId;
  50531. private _started;
  50532. private _stopped;
  50533. private _timeDelta;
  50534. private _randomTexture;
  50535. private _randomTexture2;
  50536. private _attributesStrideSize;
  50537. private _updateEffectOptions;
  50538. private _randomTextureSize;
  50539. private _actualFrame;
  50540. private readonly _rawTextureWidth;
  50541. /**
  50542. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50543. */
  50544. static readonly IsSupported: boolean;
  50545. /**
  50546. * An event triggered when the system is disposed.
  50547. */
  50548. onDisposeObservable: Observable<GPUParticleSystem>;
  50549. /**
  50550. * Gets the maximum number of particles active at the same time.
  50551. * @returns The max number of active particles.
  50552. */
  50553. getCapacity(): number;
  50554. /**
  50555. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50556. * to override the particles.
  50557. */
  50558. forceDepthWrite: boolean;
  50559. /**
  50560. * Gets or set the number of active particles
  50561. */
  50562. activeParticleCount: number;
  50563. private _preWarmDone;
  50564. /**
  50565. * Is this system ready to be used/rendered
  50566. * @return true if the system is ready
  50567. */
  50568. isReady(): boolean;
  50569. /**
  50570. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50571. * @returns True if it has been started, otherwise false.
  50572. */
  50573. isStarted(): boolean;
  50574. /**
  50575. * Starts the particle system and begins to emit
  50576. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50577. */
  50578. start(delay?: number): void;
  50579. /**
  50580. * Stops the particle system.
  50581. */
  50582. stop(): void;
  50583. /**
  50584. * Remove all active particles
  50585. */
  50586. reset(): void;
  50587. /**
  50588. * Returns the string "GPUParticleSystem"
  50589. * @returns a string containing the class name
  50590. */
  50591. getClassName(): string;
  50592. private _colorGradientsTexture;
  50593. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50594. /**
  50595. * Adds a new color gradient
  50596. * @param gradient defines the gradient to use (between 0 and 1)
  50597. * @param color1 defines the color to affect to the specified gradient
  50598. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50599. * @returns the current particle system
  50600. */
  50601. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50602. /**
  50603. * Remove a specific color gradient
  50604. * @param gradient defines the gradient to remove
  50605. * @returns the current particle system
  50606. */
  50607. removeColorGradient(gradient: number): GPUParticleSystem;
  50608. private _angularSpeedGradientsTexture;
  50609. private _sizeGradientsTexture;
  50610. private _velocityGradientsTexture;
  50611. private _limitVelocityGradientsTexture;
  50612. private _dragGradientsTexture;
  50613. private _addFactorGradient;
  50614. /**
  50615. * Adds a new size gradient
  50616. * @param gradient defines the gradient to use (between 0 and 1)
  50617. * @param factor defines the size factor to affect to the specified gradient
  50618. * @returns the current particle system
  50619. */
  50620. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50621. /**
  50622. * Remove a specific size gradient
  50623. * @param gradient defines the gradient to remove
  50624. * @returns the current particle system
  50625. */
  50626. removeSizeGradient(gradient: number): GPUParticleSystem;
  50627. /**
  50628. * Adds a new angular speed gradient
  50629. * @param gradient defines the gradient to use (between 0 and 1)
  50630. * @param factor defines the angular speed to affect to the specified gradient
  50631. * @returns the current particle system
  50632. */
  50633. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50634. /**
  50635. * Remove a specific angular speed gradient
  50636. * @param gradient defines the gradient to remove
  50637. * @returns the current particle system
  50638. */
  50639. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50640. /**
  50641. * Adds a new velocity gradient
  50642. * @param gradient defines the gradient to use (between 0 and 1)
  50643. * @param factor defines the velocity to affect to the specified gradient
  50644. * @returns the current particle system
  50645. */
  50646. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50647. /**
  50648. * Remove a specific velocity gradient
  50649. * @param gradient defines the gradient to remove
  50650. * @returns the current particle system
  50651. */
  50652. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50653. /**
  50654. * Adds a new limit velocity gradient
  50655. * @param gradient defines the gradient to use (between 0 and 1)
  50656. * @param factor defines the limit velocity value to affect to the specified gradient
  50657. * @returns the current particle system
  50658. */
  50659. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50660. /**
  50661. * Remove a specific limit velocity gradient
  50662. * @param gradient defines the gradient to remove
  50663. * @returns the current particle system
  50664. */
  50665. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50666. /**
  50667. * Adds a new drag gradient
  50668. * @param gradient defines the gradient to use (between 0 and 1)
  50669. * @param factor defines the drag value to affect to the specified gradient
  50670. * @returns the current particle system
  50671. */
  50672. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50673. /**
  50674. * Remove a specific drag gradient
  50675. * @param gradient defines the gradient to remove
  50676. * @returns the current particle system
  50677. */
  50678. removeDragGradient(gradient: number): GPUParticleSystem;
  50679. /**
  50680. * Not supported by GPUParticleSystem
  50681. * @param gradient defines the gradient to use (between 0 and 1)
  50682. * @param factor defines the emit rate value to affect to the specified gradient
  50683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50684. * @returns the current particle system
  50685. */
  50686. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50687. /**
  50688. * Not supported by GPUParticleSystem
  50689. * @param gradient defines the gradient to remove
  50690. * @returns the current particle system
  50691. */
  50692. removeEmitRateGradient(gradient: number): IParticleSystem;
  50693. /**
  50694. * Not supported by GPUParticleSystem
  50695. * @param gradient defines the gradient to use (between 0 and 1)
  50696. * @param factor defines the start size value to affect to the specified gradient
  50697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50698. * @returns the current particle system
  50699. */
  50700. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50701. /**
  50702. * Not supported by GPUParticleSystem
  50703. * @param gradient defines the gradient to remove
  50704. * @returns the current particle system
  50705. */
  50706. removeStartSizeGradient(gradient: number): IParticleSystem;
  50707. /**
  50708. * Not supported by GPUParticleSystem
  50709. * @param gradient defines the gradient to use (between 0 and 1)
  50710. * @param min defines the color remap minimal range
  50711. * @param max defines the color remap maximal range
  50712. * @returns the current particle system
  50713. */
  50714. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50715. /**
  50716. * Not supported by GPUParticleSystem
  50717. * @param gradient defines the gradient to remove
  50718. * @returns the current particle system
  50719. */
  50720. removeColorRemapGradient(): IParticleSystem;
  50721. /**
  50722. * Not supported by GPUParticleSystem
  50723. * @param gradient defines the gradient to use (between 0 and 1)
  50724. * @param min defines the alpha remap minimal range
  50725. * @param max defines the alpha remap maximal range
  50726. * @returns the current particle system
  50727. */
  50728. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50729. /**
  50730. * Not supported by GPUParticleSystem
  50731. * @param gradient defines the gradient to remove
  50732. * @returns the current particle system
  50733. */
  50734. removeAlphaRemapGradient(): IParticleSystem;
  50735. /**
  50736. * Not supported by GPUParticleSystem
  50737. * @param gradient defines the gradient to use (between 0 and 1)
  50738. * @param color defines the color to affect to the specified gradient
  50739. * @returns the current particle system
  50740. */
  50741. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50742. /**
  50743. * Not supported by GPUParticleSystem
  50744. * @param gradient defines the gradient to remove
  50745. * @returns the current particle system
  50746. */
  50747. removeRampGradient(): IParticleSystem;
  50748. /**
  50749. * Not supported by GPUParticleSystem
  50750. * @returns the list of ramp gradients
  50751. */
  50752. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50753. /**
  50754. * Not supported by GPUParticleSystem
  50755. * Gets or sets a boolean indicating that ramp gradients must be used
  50756. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50757. */
  50758. useRampGradients: boolean;
  50759. /**
  50760. * Not supported by GPUParticleSystem
  50761. * @param gradient defines the gradient to use (between 0 and 1)
  50762. * @param factor defines the life time factor to affect to the specified gradient
  50763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50764. * @returns the current particle system
  50765. */
  50766. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50767. /**
  50768. * Not supported by GPUParticleSystem
  50769. * @param gradient defines the gradient to remove
  50770. * @returns the current particle system
  50771. */
  50772. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50773. /**
  50774. * Instantiates a GPU particle system.
  50775. * 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.
  50776. * @param name The name of the particle system
  50777. * @param options The options used to create the system
  50778. * @param scene The scene the particle system belongs to
  50779. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50780. */
  50781. constructor(name: string, options: Partial<{
  50782. capacity: number;
  50783. randomTextureSize: number;
  50784. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50785. protected _reset(): void;
  50786. private _createUpdateVAO;
  50787. private _createRenderVAO;
  50788. private _initialize;
  50789. /** @hidden */ recreateUpdateEffect(): void;
  50790. /** @hidden */ recreateRenderEffect(): void;
  50791. /**
  50792. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50793. * @param preWarm defines if we are in the pre-warmimg phase
  50794. */
  50795. animate(preWarm?: boolean): void;
  50796. private _createFactorGradientTexture;
  50797. private _createSizeGradientTexture;
  50798. private _createAngularSpeedGradientTexture;
  50799. private _createVelocityGradientTexture;
  50800. private _createLimitVelocityGradientTexture;
  50801. private _createDragGradientTexture;
  50802. private _createColorGradientTexture;
  50803. /**
  50804. * Renders the particle system in its current state
  50805. * @param preWarm defines if the system should only update the particles but not render them
  50806. * @returns the current number of particles
  50807. */
  50808. render(preWarm?: boolean): number;
  50809. /**
  50810. * Rebuilds the particle system
  50811. */
  50812. rebuild(): void;
  50813. private _releaseBuffers;
  50814. private _releaseVAOs;
  50815. /**
  50816. * Disposes the particle system and free the associated resources
  50817. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50818. */
  50819. dispose(disposeTexture?: boolean): void;
  50820. /**
  50821. * Clones the particle system.
  50822. * @param name The name of the cloned object
  50823. * @param newEmitter The new emitter to use
  50824. * @returns the cloned particle system
  50825. */
  50826. clone(name: string, newEmitter: any): GPUParticleSystem;
  50827. /**
  50828. * Serializes the particle system to a JSON object.
  50829. * @returns the JSON object
  50830. */
  50831. serialize(): any;
  50832. /**
  50833. * Parses a JSON object to create a GPU particle system.
  50834. * @param parsedParticleSystem The JSON object to parse
  50835. * @param scene The scene to create the particle system in
  50836. * @param rootUrl The root url to use to load external dependencies like texture
  50837. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50838. * @returns the parsed GPU particle system
  50839. */
  50840. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50841. }
  50842. }
  50843. declare module BABYLON {
  50844. /**
  50845. * Represents a set of particle systems working together to create a specific effect
  50846. */
  50847. export class ParticleSystemSet implements IDisposable {
  50848. private _emitterCreationOptions;
  50849. private _emitterNode;
  50850. /**
  50851. * Gets the particle system list
  50852. */
  50853. systems: IParticleSystem[];
  50854. /**
  50855. * Gets the emitter node used with this set
  50856. */
  50857. readonly emitterNode: Nullable<TransformNode>;
  50858. /**
  50859. * Creates a new emitter mesh as a sphere
  50860. * @param options defines the options used to create the sphere
  50861. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50862. * @param scene defines the hosting scene
  50863. */
  50864. setEmitterAsSphere(options: {
  50865. diameter: number;
  50866. segments: number;
  50867. color: Color3;
  50868. }, renderingGroupId: number, scene: Scene): void;
  50869. /**
  50870. * Starts all particle systems of the set
  50871. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50872. */
  50873. start(emitter?: AbstractMesh): void;
  50874. /**
  50875. * Release all associated resources
  50876. */
  50877. dispose(): void;
  50878. /**
  50879. * Serialize the set into a JSON compatible object
  50880. * @returns a JSON compatible representation of the set
  50881. */
  50882. serialize(): any;
  50883. /**
  50884. * Parse a new ParticleSystemSet from a serialized source
  50885. * @param data defines a JSON compatible representation of the set
  50886. * @param scene defines the hosting scene
  50887. * @param gpu defines if we want GPU particles or CPU particles
  50888. * @returns a new ParticleSystemSet
  50889. */
  50890. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50891. }
  50892. }
  50893. declare module BABYLON {
  50894. /**
  50895. * This class is made for on one-liner static method to help creating particle system set.
  50896. */
  50897. export class ParticleHelper {
  50898. /**
  50899. * Gets or sets base Assets URL
  50900. */
  50901. static BaseAssetsUrl: string;
  50902. /**
  50903. * Create a default particle system that you can tweak
  50904. * @param emitter defines the emitter to use
  50905. * @param capacity defines the system capacity (default is 500 particles)
  50906. * @param scene defines the hosting scene
  50907. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50908. * @returns the new Particle system
  50909. */
  50910. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50911. /**
  50912. * This is the main static method (one-liner) of this helper to create different particle systems
  50913. * @param type This string represents the type to the particle system to create
  50914. * @param scene The scene where the particle system should live
  50915. * @param gpu If the system will use gpu
  50916. * @returns the ParticleSystemSet created
  50917. */
  50918. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50919. /**
  50920. * Static function used to export a particle system to a ParticleSystemSet variable.
  50921. * Please note that the emitter shape is not exported
  50922. * @param systems defines the particle systems to export
  50923. * @returns the created particle system set
  50924. */
  50925. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50926. }
  50927. }
  50928. declare module BABYLON {
  50929. interface Engine {
  50930. /**
  50931. * Create an effect to use with particle systems.
  50932. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50933. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50934. * @param uniformsNames defines a list of attribute names
  50935. * @param samplers defines an array of string used to represent textures
  50936. * @param defines defines the string containing the defines to use to compile the shaders
  50937. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50938. * @param onCompiled defines a function to call when the effect creation is successful
  50939. * @param onError defines a function to call when the effect creation has failed
  50940. * @returns the new Effect
  50941. */
  50942. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50943. }
  50944. interface Mesh {
  50945. /**
  50946. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50947. * @returns an array of IParticleSystem
  50948. */
  50949. getEmittedParticleSystems(): IParticleSystem[];
  50950. /**
  50951. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50952. * @returns an array of IParticleSystem
  50953. */
  50954. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50955. }
  50956. /**
  50957. * @hidden
  50958. */
  50959. export var _IDoNeedToBeInTheBuild: number;
  50960. }
  50961. declare module BABYLON {
  50962. interface Scene {
  50963. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  50964. /**
  50965. * Gets the current physics engine
  50966. * @returns a IPhysicsEngine or null if none attached
  50967. */
  50968. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50969. /**
  50970. * Enables physics to the current scene
  50971. * @param gravity defines the scene's gravity for the physics engine
  50972. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50973. * @return a boolean indicating if the physics engine was initialized
  50974. */
  50975. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50976. /**
  50977. * Disables and disposes the physics engine associated with the scene
  50978. */
  50979. disablePhysicsEngine(): void;
  50980. /**
  50981. * Gets a boolean indicating if there is an active physics engine
  50982. * @returns a boolean indicating if there is an active physics engine
  50983. */
  50984. isPhysicsEnabled(): boolean;
  50985. /**
  50986. * Deletes a physics compound impostor
  50987. * @param compound defines the compound to delete
  50988. */
  50989. deleteCompoundImpostor(compound: any): void;
  50990. /**
  50991. * An event triggered when physic simulation is about to be run
  50992. */
  50993. onBeforePhysicsObservable: Observable<Scene>;
  50994. /**
  50995. * An event triggered when physic simulation has been done
  50996. */
  50997. onAfterPhysicsObservable: Observable<Scene>;
  50998. }
  50999. interface AbstractMesh {
  51000. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  51001. /**
  51002. * Gets or sets impostor used for physic simulation
  51003. * @see http://doc.babylonjs.com/features/physics_engine
  51004. */
  51005. physicsImpostor: Nullable<PhysicsImpostor>;
  51006. /**
  51007. * Gets the current physics impostor
  51008. * @see http://doc.babylonjs.com/features/physics_engine
  51009. * @returns a physics impostor or null
  51010. */
  51011. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51012. /** Apply a physic impulse to the mesh
  51013. * @param force defines the force to apply
  51014. * @param contactPoint defines where to apply the force
  51015. * @returns the current mesh
  51016. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51017. */
  51018. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51019. /**
  51020. * Creates a physic joint between two meshes
  51021. * @param otherMesh defines the other mesh to use
  51022. * @param pivot1 defines the pivot to use on this mesh
  51023. * @param pivot2 defines the pivot to use on the other mesh
  51024. * @param options defines additional options (can be plugin dependent)
  51025. * @returns the current mesh
  51026. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51027. */
  51028. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51029. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  51030. }
  51031. /**
  51032. * Defines the physics engine scene component responsible to manage a physics engine
  51033. */
  51034. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51035. /**
  51036. * The component name helpful to identify the component in the list of scene components.
  51037. */
  51038. readonly name: string;
  51039. /**
  51040. * The scene the component belongs to.
  51041. */
  51042. scene: Scene;
  51043. /**
  51044. * Creates a new instance of the component for the given scene
  51045. * @param scene Defines the scene to register the component in
  51046. */
  51047. constructor(scene: Scene);
  51048. /**
  51049. * Registers the component in a given scene
  51050. */
  51051. register(): void;
  51052. /**
  51053. * Rebuilds the elements related to this component in case of
  51054. * context lost for instance.
  51055. */
  51056. rebuild(): void;
  51057. /**
  51058. * Disposes the component and the associated ressources
  51059. */
  51060. dispose(): void;
  51061. }
  51062. }
  51063. declare module BABYLON {
  51064. /**
  51065. * A helper for physics simulations
  51066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51067. */
  51068. export class PhysicsHelper {
  51069. private _scene;
  51070. private _physicsEngine;
  51071. /**
  51072. * Initializes the Physics helper
  51073. * @param scene Babylon.js scene
  51074. */
  51075. constructor(scene: Scene);
  51076. /**
  51077. * Applies a radial explosion impulse
  51078. * @param origin the origin of the explosion
  51079. * @param radiusOrEventOptions the radius or the options of radial explosion
  51080. * @param strength the explosion strength
  51081. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51082. * @returns A physics radial explosion event, or null
  51083. */
  51084. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51085. /**
  51086. * Applies a radial explosion force
  51087. * @param origin the origin of the explosion
  51088. * @param radiusOrEventOptions the radius or the options of radial explosion
  51089. * @param strength the explosion strength
  51090. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51091. * @returns A physics radial explosion event, or null
  51092. */
  51093. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51094. /**
  51095. * Creates a gravitational field
  51096. * @param origin the origin of the explosion
  51097. * @param radiusOrEventOptions the radius or the options of radial explosion
  51098. * @param strength the explosion strength
  51099. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51100. * @returns A physics gravitational field event, or null
  51101. */
  51102. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51103. /**
  51104. * Creates a physics updraft event
  51105. * @param origin the origin of the updraft
  51106. * @param radiusOrEventOptions the radius or the options of the updraft
  51107. * @param strength the strength of the updraft
  51108. * @param height the height of the updraft
  51109. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51110. * @returns A physics updraft event, or null
  51111. */
  51112. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51113. /**
  51114. * Creates a physics vortex event
  51115. * @param origin the of the vortex
  51116. * @param radiusOrEventOptions the radius or the options of the vortex
  51117. * @param strength the strength of the vortex
  51118. * @param height the height of the vortex
  51119. * @returns a Physics vortex event, or null
  51120. * A physics vortex event or null
  51121. */
  51122. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51123. }
  51124. /**
  51125. * Represents a physics radial explosion event
  51126. */
  51127. class PhysicsRadialExplosionEvent {
  51128. private _scene;
  51129. private _options;
  51130. private _sphere;
  51131. private _dataFetched;
  51132. /**
  51133. * Initializes a radial explosioin event
  51134. * @param _scene BabylonJS scene
  51135. * @param _options The options for the vortex event
  51136. */
  51137. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51138. /**
  51139. * Returns the data related to the radial explosion event (sphere).
  51140. * @returns The radial explosion event data
  51141. */
  51142. getData(): PhysicsRadialExplosionEventData;
  51143. /**
  51144. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51145. * @param impostor A physics imposter
  51146. * @param origin the origin of the explosion
  51147. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51148. */
  51149. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51150. /**
  51151. * Triggers affecterd impostors callbacks
  51152. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51153. */
  51154. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51155. /**
  51156. * Disposes the sphere.
  51157. * @param force Specifies if the sphere should be disposed by force
  51158. */
  51159. dispose(force?: boolean): void;
  51160. /*** Helpers ***/
  51161. private _prepareSphere;
  51162. private _intersectsWithSphere;
  51163. }
  51164. /**
  51165. * Represents a gravitational field event
  51166. */
  51167. class PhysicsGravitationalFieldEvent {
  51168. private _physicsHelper;
  51169. private _scene;
  51170. private _origin;
  51171. private _options;
  51172. private _tickCallback;
  51173. private _sphere;
  51174. private _dataFetched;
  51175. /**
  51176. * Initializes the physics gravitational field event
  51177. * @param _physicsHelper A physics helper
  51178. * @param _scene BabylonJS scene
  51179. * @param _origin The origin position of the gravitational field event
  51180. * @param _options The options for the vortex event
  51181. */
  51182. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51183. /**
  51184. * Returns the data related to the gravitational field event (sphere).
  51185. * @returns A gravitational field event
  51186. */
  51187. getData(): PhysicsGravitationalFieldEventData;
  51188. /**
  51189. * Enables the gravitational field.
  51190. */
  51191. enable(): void;
  51192. /**
  51193. * Disables the gravitational field.
  51194. */
  51195. disable(): void;
  51196. /**
  51197. * Disposes the sphere.
  51198. * @param force The force to dispose from the gravitational field event
  51199. */
  51200. dispose(force?: boolean): void;
  51201. private _tick;
  51202. }
  51203. /**
  51204. * Represents a physics updraft event
  51205. */
  51206. class PhysicsUpdraftEvent {
  51207. private _scene;
  51208. private _origin;
  51209. private _options;
  51210. private _physicsEngine;
  51211. private _originTop;
  51212. private _originDirection;
  51213. private _tickCallback;
  51214. private _cylinder;
  51215. private _cylinderPosition;
  51216. private _dataFetched;
  51217. /**
  51218. * Initializes the physics updraft event
  51219. * @param _scene BabylonJS scene
  51220. * @param _origin The origin position of the updraft
  51221. * @param _options The options for the updraft event
  51222. */
  51223. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  51224. /**
  51225. * Returns the data related to the updraft event (cylinder).
  51226. * @returns A physics updraft event
  51227. */
  51228. getData(): PhysicsUpdraftEventData;
  51229. /**
  51230. * Enables the updraft.
  51231. */
  51232. enable(): void;
  51233. /**
  51234. * Disables the updraft.
  51235. */
  51236. disable(): void;
  51237. /**
  51238. * Disposes the cylinder.
  51239. * @param force Specifies if the updraft should be disposed by force
  51240. */
  51241. dispose(force?: boolean): void;
  51242. private getImpostorHitData;
  51243. private _tick;
  51244. /*** Helpers ***/
  51245. private _prepareCylinder;
  51246. private _intersectsWithCylinder;
  51247. }
  51248. /**
  51249. * Represents a physics vortex event
  51250. */
  51251. class PhysicsVortexEvent {
  51252. private _scene;
  51253. private _origin;
  51254. private _options;
  51255. private _physicsEngine;
  51256. private _originTop;
  51257. private _tickCallback;
  51258. private _cylinder;
  51259. private _cylinderPosition;
  51260. private _dataFetched;
  51261. /**
  51262. * Initializes the physics vortex event
  51263. * @param _scene The BabylonJS scene
  51264. * @param _origin The origin position of the vortex
  51265. * @param _options The options for the vortex event
  51266. */
  51267. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  51268. /**
  51269. * Returns the data related to the vortex event (cylinder).
  51270. * @returns The physics vortex event data
  51271. */
  51272. getData(): PhysicsVortexEventData;
  51273. /**
  51274. * Enables the vortex.
  51275. */
  51276. enable(): void;
  51277. /**
  51278. * Disables the cortex.
  51279. */
  51280. disable(): void;
  51281. /**
  51282. * Disposes the sphere.
  51283. * @param force
  51284. */
  51285. dispose(force?: boolean): void;
  51286. private getImpostorHitData;
  51287. private _tick;
  51288. /*** Helpers ***/
  51289. private _prepareCylinder;
  51290. private _intersectsWithCylinder;
  51291. }
  51292. /**
  51293. * Options fot the radial explosion event
  51294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51295. */
  51296. export class PhysicsRadialExplosionEventOptions {
  51297. /**
  51298. * The radius of the sphere for the radial explosion.
  51299. */
  51300. radius: number;
  51301. /**
  51302. * The strenth of the explosion.
  51303. */
  51304. strength: number;
  51305. /**
  51306. * The strenght of the force in correspondence to the distance of the affected object
  51307. */
  51308. falloff: PhysicsRadialImpulseFalloff;
  51309. /**
  51310. * Sphere options for the radial explosion.
  51311. */
  51312. sphere: {
  51313. segments: number;
  51314. diameter: number;
  51315. };
  51316. /**
  51317. * Sphere options for the radial explosion.
  51318. */
  51319. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  51320. }
  51321. /**
  51322. * Options fot the updraft event
  51323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51324. */
  51325. export class PhysicsUpdraftEventOptions {
  51326. /**
  51327. * The radius of the cylinder for the vortex
  51328. */
  51329. radius: number;
  51330. /**
  51331. * The strenth of the updraft.
  51332. */
  51333. strength: number;
  51334. /**
  51335. * The height of the cylinder for the updraft.
  51336. */
  51337. height: number;
  51338. /**
  51339. * The mode for the the updraft.
  51340. */
  51341. updraftMode: PhysicsUpdraftMode;
  51342. }
  51343. /**
  51344. * Options fot the vortex event
  51345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51346. */
  51347. export class PhysicsVortexEventOptions {
  51348. /**
  51349. * The radius of the cylinder for the vortex
  51350. */
  51351. radius: number;
  51352. /**
  51353. * The strenth of the vortex.
  51354. */
  51355. strength: number;
  51356. /**
  51357. * The height of the cylinder for the vortex.
  51358. */
  51359. height: number;
  51360. /**
  51361. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51362. */
  51363. centripetalForceThreshold: number;
  51364. /**
  51365. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51366. */
  51367. centripetalForceMultiplier: number;
  51368. /**
  51369. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51370. */
  51371. centrifugalForceMultiplier: number;
  51372. /**
  51373. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51374. */
  51375. updraftForceMultiplier: number;
  51376. }
  51377. /**
  51378. * The strenght of the force in correspondence to the distance of the affected object
  51379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51380. */
  51381. export enum PhysicsRadialImpulseFalloff {
  51382. /** Defines that impulse is constant in strength across it's whole radius */
  51383. Constant = 0,
  51384. /** Defines that impulse gets weaker if it's further from the origin */
  51385. Linear = 1
  51386. }
  51387. /**
  51388. * The strength of the force in correspondence to the distance of the affected object
  51389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51390. */
  51391. export enum PhysicsUpdraftMode {
  51392. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51393. Center = 0,
  51394. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51395. Perpendicular = 1
  51396. }
  51397. /**
  51398. * Interface for a physics hit data
  51399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51400. */
  51401. export interface PhysicsHitData {
  51402. /**
  51403. * The force applied at the contact point
  51404. */
  51405. force: Vector3;
  51406. /**
  51407. * The contact point
  51408. */
  51409. contactPoint: Vector3;
  51410. /**
  51411. * The distance from the origin to the contact point
  51412. */
  51413. distanceFromOrigin: number;
  51414. }
  51415. /**
  51416. * Interface for radial explosion event data
  51417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51418. */
  51419. export interface PhysicsRadialExplosionEventData {
  51420. /**
  51421. * A sphere used for the radial explosion event
  51422. */
  51423. sphere: Mesh;
  51424. }
  51425. /**
  51426. * Interface for gravitational field event data
  51427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51428. */
  51429. export interface PhysicsGravitationalFieldEventData {
  51430. /**
  51431. * A sphere mesh used for the gravitational field event
  51432. */
  51433. sphere: Mesh;
  51434. }
  51435. /**
  51436. * Interface for updraft event data
  51437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51438. */
  51439. export interface PhysicsUpdraftEventData {
  51440. /**
  51441. * A cylinder used for the updraft event
  51442. */
  51443. cylinder: Mesh;
  51444. }
  51445. /**
  51446. * Interface for vortex event data
  51447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51448. */
  51449. export interface PhysicsVortexEventData {
  51450. /**
  51451. * A cylinder used for the vortex event
  51452. */
  51453. cylinder: Mesh;
  51454. }
  51455. /**
  51456. * Interface for an affected physics impostor
  51457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51458. */
  51459. export interface PhysicsAffectedImpostorWithData {
  51460. /**
  51461. * The impostor affected by the effect
  51462. */
  51463. impostor: PhysicsImpostor;
  51464. /**
  51465. * The data about the hit/horce from the explosion
  51466. */
  51467. hitData: PhysicsHitData;
  51468. }
  51469. }
  51470. declare module BABYLON {
  51471. /** @hidden */
  51472. export var blackAndWhitePixelShader: {
  51473. name: string;
  51474. shader: string;
  51475. };
  51476. }
  51477. declare module BABYLON {
  51478. /**
  51479. * Post process used to render in black and white
  51480. */
  51481. export class BlackAndWhitePostProcess extends PostProcess {
  51482. /**
  51483. * Linear about to convert he result to black and white (default: 1)
  51484. */
  51485. degree: number;
  51486. /**
  51487. * Creates a black and white post process
  51488. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51489. * @param name The name of the effect.
  51490. * @param options The required width/height ratio to downsize to before computing the render pass.
  51491. * @param camera The camera to apply the render pass to.
  51492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51493. * @param engine The engine which the post process will be applied. (default: current engine)
  51494. * @param reusable If the post process can be reused on the same frame. (default: false)
  51495. */
  51496. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51497. }
  51498. }
  51499. declare module BABYLON {
  51500. /**
  51501. * This represents a set of one or more post processes in Babylon.
  51502. * A post process can be used to apply a shader to a texture after it is rendered.
  51503. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51504. */
  51505. export class PostProcessRenderEffect {
  51506. private _postProcesses;
  51507. private _getPostProcesses;
  51508. private _singleInstance;
  51509. private _cameras;
  51510. private _indicesForCamera;
  51511. /**
  51512. * Name of the effect
  51513. * @hidden
  51514. */ name: string;
  51515. /**
  51516. * Instantiates a post process render effect.
  51517. * A post process can be used to apply a shader to a texture after it is rendered.
  51518. * @param engine The engine the effect is tied to
  51519. * @param name The name of the effect
  51520. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51521. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51522. */
  51523. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51524. /**
  51525. * Checks if all the post processes in the effect are supported.
  51526. */
  51527. readonly isSupported: boolean;
  51528. /**
  51529. * Updates the current state of the effect
  51530. * @hidden
  51531. */ update(): void;
  51532. /**
  51533. * Attaches the effect on cameras
  51534. * @param cameras The camera to attach to.
  51535. * @hidden
  51536. */ attachCameras(cameras: Camera): void;
  51537. /**
  51538. * Attaches the effect on cameras
  51539. * @param cameras The camera to attach to.
  51540. * @hidden
  51541. */ attachCameras(cameras: Camera[]): void;
  51542. /**
  51543. * Detaches the effect on cameras
  51544. * @param cameras The camera to detatch from.
  51545. * @hidden
  51546. */ detachCameras(cameras: Camera): void;
  51547. /**
  51548. * Detatches the effect on cameras
  51549. * @param cameras The camera to detatch from.
  51550. * @hidden
  51551. */ detachCameras(cameras: Camera[]): void;
  51552. /**
  51553. * Enables the effect on given cameras
  51554. * @param cameras The camera to enable.
  51555. * @hidden
  51556. */ enable(cameras: Camera): void;
  51557. /**
  51558. * Enables the effect on given cameras
  51559. * @param cameras The camera to enable.
  51560. * @hidden
  51561. */ enable(cameras: Nullable<Camera[]>): void;
  51562. /**
  51563. * Disables the effect on the given cameras
  51564. * @param cameras The camera to disable.
  51565. * @hidden
  51566. */ disable(cameras: Camera): void;
  51567. /**
  51568. * Disables the effect on the given cameras
  51569. * @param cameras The camera to disable.
  51570. * @hidden
  51571. */ disable(cameras: Nullable<Camera[]>): void;
  51572. /**
  51573. * Gets a list of the post processes contained in the effect.
  51574. * @param camera The camera to get the post processes on.
  51575. * @returns The list of the post processes in the effect.
  51576. */
  51577. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51578. }
  51579. }
  51580. declare module BABYLON {
  51581. /** @hidden */
  51582. export var extractHighlightsPixelShader: {
  51583. name: string;
  51584. shader: string;
  51585. };
  51586. }
  51587. declare module BABYLON {
  51588. /**
  51589. * 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.
  51590. */
  51591. export class ExtractHighlightsPostProcess extends PostProcess {
  51592. /**
  51593. * The luminance threshold, pixels below this value will be set to black.
  51594. */
  51595. threshold: number;
  51596. /** @hidden */ exposure: number;
  51597. /**
  51598. * Post process which has the input texture to be used when performing highlight extraction
  51599. * @hidden
  51600. */ inputPostProcess: Nullable<PostProcess>;
  51601. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51602. }
  51603. }
  51604. declare module BABYLON {
  51605. /** @hidden */
  51606. export var bloomMergePixelShader: {
  51607. name: string;
  51608. shader: string;
  51609. };
  51610. }
  51611. declare module BABYLON {
  51612. /**
  51613. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51614. */
  51615. export class BloomMergePostProcess extends PostProcess {
  51616. /** Weight of the bloom to be added to the original input. */
  51617. weight: number;
  51618. /**
  51619. * Creates a new instance of @see BloomMergePostProcess
  51620. * @param name The name of the effect.
  51621. * @param originalFromInput Post process which's input will be used for the merge.
  51622. * @param blurred Blurred highlights post process which's output will be used.
  51623. * @param weight Weight of the bloom to be added to the original input.
  51624. * @param options The required width/height ratio to downsize to before computing the render pass.
  51625. * @param camera The camera to apply the render pass to.
  51626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51627. * @param engine The engine which the post process will be applied. (default: current engine)
  51628. * @param reusable If the post process can be reused on the same frame. (default: false)
  51629. * @param textureType Type of textures used when performing the post process. (default: 0)
  51630. * @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)
  51631. */
  51632. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51633. /** Weight of the bloom to be added to the original input. */
  51634. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51635. }
  51636. }
  51637. declare module BABYLON {
  51638. /**
  51639. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51640. */
  51641. export class BloomEffect extends PostProcessRenderEffect {
  51642. private bloomScale;
  51643. /**
  51644. * @hidden Internal
  51645. */ effects: Array<PostProcess>;
  51646. /**
  51647. * @hidden Internal
  51648. */ downscale: ExtractHighlightsPostProcess;
  51649. private _blurX;
  51650. private _blurY;
  51651. private _merge;
  51652. /**
  51653. * The luminance threshold to find bright areas of the image to bloom.
  51654. */
  51655. threshold: number;
  51656. /**
  51657. * The strength of the bloom.
  51658. */
  51659. weight: number;
  51660. /**
  51661. * Specifies the size of the bloom blur kernel, relative to the final output size
  51662. */
  51663. kernel: number;
  51664. /**
  51665. * Creates a new instance of @see BloomEffect
  51666. * @param scene The scene the effect belongs to.
  51667. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51668. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51669. * @param bloomWeight The the strength of bloom.
  51670. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51671. * @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)
  51672. */
  51673. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51674. /**
  51675. * Disposes each of the internal effects for a given camera.
  51676. * @param camera The camera to dispose the effect on.
  51677. */
  51678. disposeEffects(camera: Camera): void;
  51679. /**
  51680. * @hidden Internal
  51681. */ updateEffects(): void;
  51682. /**
  51683. * Internal
  51684. * @returns if all the contained post processes are ready.
  51685. * @hidden
  51686. */ isReady(): boolean;
  51687. }
  51688. }
  51689. declare module BABYLON {
  51690. /** @hidden */
  51691. export var chromaticAberrationPixelShader: {
  51692. name: string;
  51693. shader: string;
  51694. };
  51695. }
  51696. declare module BABYLON {
  51697. /**
  51698. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51699. */
  51700. export class ChromaticAberrationPostProcess extends PostProcess {
  51701. /**
  51702. * The amount of seperation of rgb channels (default: 30)
  51703. */
  51704. aberrationAmount: number;
  51705. /**
  51706. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51707. */
  51708. radialIntensity: number;
  51709. /**
  51710. * 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))
  51711. */
  51712. direction: Vector2;
  51713. /**
  51714. * 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))
  51715. */
  51716. centerPosition: Vector2;
  51717. /**
  51718. * Creates a new instance ChromaticAberrationPostProcess
  51719. * @param name The name of the effect.
  51720. * @param screenWidth The width of the screen to apply the effect on.
  51721. * @param screenHeight The height of the screen to apply the effect on.
  51722. * @param options The required width/height ratio to downsize to before computing the render pass.
  51723. * @param camera The camera to apply the render pass to.
  51724. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51725. * @param engine The engine which the post process will be applied. (default: current engine)
  51726. * @param reusable If the post process can be reused on the same frame. (default: false)
  51727. * @param textureType Type of textures used when performing the post process. (default: 0)
  51728. * @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)
  51729. */
  51730. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51731. }
  51732. }
  51733. declare module BABYLON {
  51734. /** @hidden */
  51735. export var circleOfConfusionPixelShader: {
  51736. name: string;
  51737. shader: string;
  51738. };
  51739. }
  51740. declare module BABYLON {
  51741. /**
  51742. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51743. */
  51744. export class CircleOfConfusionPostProcess extends PostProcess {
  51745. /**
  51746. * 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.
  51747. */
  51748. lensSize: number;
  51749. /**
  51750. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51751. */
  51752. fStop: number;
  51753. /**
  51754. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51755. */
  51756. focusDistance: number;
  51757. /**
  51758. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51759. */
  51760. focalLength: number;
  51761. private _depthTexture;
  51762. /**
  51763. * Creates a new instance CircleOfConfusionPostProcess
  51764. * @param name The name of the effect.
  51765. * @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.
  51766. * @param options The required width/height ratio to downsize to before computing the render pass.
  51767. * @param camera The camera to apply the render pass to.
  51768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51769. * @param engine The engine which the post process will be applied. (default: current engine)
  51770. * @param reusable If the post process can be reused on the same frame. (default: false)
  51771. * @param textureType Type of textures used when performing the post process. (default: 0)
  51772. * @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)
  51773. */
  51774. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51775. /**
  51776. * 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.
  51777. */
  51778. depthTexture: RenderTargetTexture;
  51779. }
  51780. }
  51781. declare module BABYLON {
  51782. /** @hidden */
  51783. export var colorCorrectionPixelShader: {
  51784. name: string;
  51785. shader: string;
  51786. };
  51787. }
  51788. declare module BABYLON {
  51789. /**
  51790. *
  51791. * This post-process allows the modification of rendered colors by using
  51792. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51793. *
  51794. * The object needs to be provided an url to a texture containing the color
  51795. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51796. * Use an image editing software to tweak the LUT to match your needs.
  51797. *
  51798. * For an example of a color LUT, see here:
  51799. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51800. * For explanations on color grading, see here:
  51801. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51802. *
  51803. */
  51804. export class ColorCorrectionPostProcess extends PostProcess {
  51805. private _colorTableTexture;
  51806. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51807. }
  51808. }
  51809. declare module BABYLON {
  51810. /** @hidden */
  51811. export var convolutionPixelShader: {
  51812. name: string;
  51813. shader: string;
  51814. };
  51815. }
  51816. declare module BABYLON {
  51817. /**
  51818. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51819. * input texture to perform effects such as edge detection or sharpening
  51820. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51821. */
  51822. export class ConvolutionPostProcess extends PostProcess {
  51823. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51824. kernel: number[];
  51825. /**
  51826. * Creates a new instance ConvolutionPostProcess
  51827. * @param name The name of the effect.
  51828. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51829. * @param options The required width/height ratio to downsize to before computing the render pass.
  51830. * @param camera The camera to apply the render pass to.
  51831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51832. * @param engine The engine which the post process will be applied. (default: current engine)
  51833. * @param reusable If the post process can be reused on the same frame. (default: false)
  51834. * @param textureType Type of textures used when performing the post process. (default: 0)
  51835. */
  51836. constructor(name: string,
  51837. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51838. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51839. /**
  51840. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51841. */
  51842. static EdgeDetect0Kernel: number[];
  51843. /**
  51844. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51845. */
  51846. static EdgeDetect1Kernel: number[];
  51847. /**
  51848. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51849. */
  51850. static EdgeDetect2Kernel: number[];
  51851. /**
  51852. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51853. */
  51854. static SharpenKernel: number[];
  51855. /**
  51856. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51857. */
  51858. static EmbossKernel: number[];
  51859. /**
  51860. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51861. */
  51862. static GaussianKernel: number[];
  51863. }
  51864. }
  51865. declare module BABYLON {
  51866. /**
  51867. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51868. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51869. * based on samples that have a large difference in distance than the center pixel.
  51870. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51871. */
  51872. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51873. direction: Vector2;
  51874. /**
  51875. * Creates a new instance CircleOfConfusionPostProcess
  51876. * @param name The name of the effect.
  51877. * @param scene The scene the effect belongs to.
  51878. * @param direction The direction the blur should be applied.
  51879. * @param kernel The size of the kernel used to blur.
  51880. * @param options The required width/height ratio to downsize to before computing the render pass.
  51881. * @param camera The camera to apply the render pass to.
  51882. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51883. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51885. * @param engine The engine which the post process will be applied. (default: current engine)
  51886. * @param reusable If the post process can be reused on the same frame. (default: false)
  51887. * @param textureType Type of textures used when performing the post process. (default: 0)
  51888. * @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)
  51889. */
  51890. 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);
  51891. }
  51892. }
  51893. declare module BABYLON {
  51894. /** @hidden */
  51895. export var depthOfFieldMergePixelShader: {
  51896. name: string;
  51897. shader: string;
  51898. };
  51899. }
  51900. declare module BABYLON {
  51901. /**
  51902. * Options to be set when merging outputs from the default pipeline.
  51903. */
  51904. export class DepthOfFieldMergePostProcessOptions {
  51905. /**
  51906. * The original image to merge on top of
  51907. */
  51908. originalFromInput: PostProcess;
  51909. /**
  51910. * Parameters to perform the merge of the depth of field effect
  51911. */
  51912. depthOfField?: {
  51913. circleOfConfusion: PostProcess;
  51914. blurSteps: Array<PostProcess>;
  51915. };
  51916. /**
  51917. * Parameters to perform the merge of bloom effect
  51918. */
  51919. bloom?: {
  51920. blurred: PostProcess;
  51921. weight: number;
  51922. };
  51923. }
  51924. /**
  51925. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51926. */
  51927. export class DepthOfFieldMergePostProcess extends PostProcess {
  51928. private blurSteps;
  51929. /**
  51930. * Creates a new instance of DepthOfFieldMergePostProcess
  51931. * @param name The name of the effect.
  51932. * @param originalFromInput Post process which's input will be used for the merge.
  51933. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51934. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51935. * @param options The required width/height ratio to downsize to before computing the render pass.
  51936. * @param camera The camera to apply the render pass to.
  51937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51938. * @param engine The engine which the post process will be applied. (default: current engine)
  51939. * @param reusable If the post process can be reused on the same frame. (default: false)
  51940. * @param textureType Type of textures used when performing the post process. (default: 0)
  51941. * @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)
  51942. */
  51943. 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);
  51944. /**
  51945. * Updates the effect with the current post process compile time values and recompiles the shader.
  51946. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51947. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51948. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51949. * @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
  51950. * @param onCompiled Called when the shader has been compiled.
  51951. * @param onError Called if there is an error when compiling a shader.
  51952. */
  51953. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51954. }
  51955. }
  51956. declare module BABYLON {
  51957. /**
  51958. * Specifies the level of max blur that should be applied when using the depth of field effect
  51959. */
  51960. export enum DepthOfFieldEffectBlurLevel {
  51961. /**
  51962. * Subtle blur
  51963. */
  51964. Low = 0,
  51965. /**
  51966. * Medium blur
  51967. */
  51968. Medium = 1,
  51969. /**
  51970. * Large blur
  51971. */
  51972. High = 2
  51973. }
  51974. /**
  51975. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51976. */
  51977. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51978. private _circleOfConfusion;
  51979. /**
  51980. * @hidden Internal, blurs from high to low
  51981. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51982. private _depthOfFieldBlurY;
  51983. private _dofMerge;
  51984. /**
  51985. * @hidden Internal post processes in depth of field effect
  51986. */ effects: Array<PostProcess>;
  51987. /**
  51988. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51989. */
  51990. focalLength: number;
  51991. /**
  51992. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51993. */
  51994. fStop: number;
  51995. /**
  51996. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51997. */
  51998. focusDistance: number;
  51999. /**
  52000. * 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.
  52001. */
  52002. lensSize: number;
  52003. /**
  52004. * Creates a new instance DepthOfFieldEffect
  52005. * @param scene The scene the effect belongs to.
  52006. * @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.
  52007. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52008. * @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)
  52009. */
  52010. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52011. /**
  52012. * Get the current class name of the current effet
  52013. * @returns "DepthOfFieldEffect"
  52014. */
  52015. getClassName(): string;
  52016. /**
  52017. * 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.
  52018. */
  52019. depthTexture: RenderTargetTexture;
  52020. /**
  52021. * Disposes each of the internal effects for a given camera.
  52022. * @param camera The camera to dispose the effect on.
  52023. */
  52024. disposeEffects(camera: Camera): void;
  52025. /**
  52026. * @hidden Internal
  52027. */ updateEffects(): void;
  52028. /**
  52029. * Internal
  52030. * @returns if all the contained post processes are ready.
  52031. * @hidden
  52032. */ isReady(): boolean;
  52033. }
  52034. }
  52035. declare module BABYLON {
  52036. /** @hidden */
  52037. export var displayPassPixelShader: {
  52038. name: string;
  52039. shader: string;
  52040. };
  52041. }
  52042. declare module BABYLON {
  52043. /**
  52044. * DisplayPassPostProcess which produces an output the same as it's input
  52045. */
  52046. export class DisplayPassPostProcess extends PostProcess {
  52047. /**
  52048. * Creates the DisplayPassPostProcess
  52049. * @param name The name of the effect.
  52050. * @param options The required width/height ratio to downsize to before computing the render pass.
  52051. * @param camera The camera to apply the render pass to.
  52052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52053. * @param engine The engine which the post process will be applied. (default: current engine)
  52054. * @param reusable If the post process can be reused on the same frame. (default: false)
  52055. */
  52056. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52057. }
  52058. }
  52059. declare module BABYLON {
  52060. /** @hidden */
  52061. export var filterPixelShader: {
  52062. name: string;
  52063. shader: string;
  52064. };
  52065. }
  52066. declare module BABYLON {
  52067. /**
  52068. * Applies a kernel filter to the image
  52069. */
  52070. export class FilterPostProcess extends PostProcess {
  52071. /** The matrix to be applied to the image */
  52072. kernelMatrix: Matrix;
  52073. /**
  52074. *
  52075. * @param name The name of the effect.
  52076. * @param kernelMatrix The matrix to be applied to the image
  52077. * @param options The required width/height ratio to downsize to before computing the render pass.
  52078. * @param camera The camera to apply the render pass to.
  52079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52080. * @param engine The engine which the post process will be applied. (default: current engine)
  52081. * @param reusable If the post process can be reused on the same frame. (default: false)
  52082. */
  52083. constructor(name: string,
  52084. /** The matrix to be applied to the image */
  52085. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52086. }
  52087. }
  52088. declare module BABYLON {
  52089. /** @hidden */
  52090. export var fxaaPixelShader: {
  52091. name: string;
  52092. shader: string;
  52093. };
  52094. }
  52095. declare module BABYLON {
  52096. /** @hidden */
  52097. export var fxaaVertexShader: {
  52098. name: string;
  52099. shader: string;
  52100. };
  52101. }
  52102. declare module BABYLON {
  52103. /**
  52104. * Fxaa post process
  52105. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52106. */
  52107. export class FxaaPostProcess extends PostProcess {
  52108. /** @hidden */
  52109. texelWidth: number;
  52110. /** @hidden */
  52111. texelHeight: number;
  52112. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52113. private _getDefines;
  52114. }
  52115. }
  52116. declare module BABYLON {
  52117. /** @hidden */
  52118. export var grainPixelShader: {
  52119. name: string;
  52120. shader: string;
  52121. };
  52122. }
  52123. declare module BABYLON {
  52124. /**
  52125. * The GrainPostProcess adds noise to the image at mid luminance levels
  52126. */
  52127. export class GrainPostProcess extends PostProcess {
  52128. /**
  52129. * The intensity of the grain added (default: 30)
  52130. */
  52131. intensity: number;
  52132. /**
  52133. * If the grain should be randomized on every frame
  52134. */
  52135. animated: boolean;
  52136. /**
  52137. * Creates a new instance of @see GrainPostProcess
  52138. * @param name The name of the effect.
  52139. * @param options The required width/height ratio to downsize to before computing the render pass.
  52140. * @param camera The camera to apply the render pass to.
  52141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52142. * @param engine The engine which the post process will be applied. (default: current engine)
  52143. * @param reusable If the post process can be reused on the same frame. (default: false)
  52144. * @param textureType Type of textures used when performing the post process. (default: 0)
  52145. * @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)
  52146. */
  52147. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52148. }
  52149. }
  52150. declare module BABYLON {
  52151. /** @hidden */
  52152. export var highlightsPixelShader: {
  52153. name: string;
  52154. shader: string;
  52155. };
  52156. }
  52157. declare module BABYLON {
  52158. /**
  52159. * Extracts highlights from the image
  52160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52161. */
  52162. export class HighlightsPostProcess extends PostProcess {
  52163. /**
  52164. * Extracts highlights from the image
  52165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52166. * @param name The name of the effect.
  52167. * @param options The required width/height ratio to downsize to before computing the render pass.
  52168. * @param camera The camera to apply the render pass to.
  52169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52170. * @param engine The engine which the post process will be applied. (default: current engine)
  52171. * @param reusable If the post process can be reused on the same frame. (default: false)
  52172. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52173. */
  52174. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52175. }
  52176. }
  52177. declare module BABYLON {
  52178. /** @hidden */
  52179. export var mrtFragmentDeclaration: {
  52180. name: string;
  52181. shader: string;
  52182. };
  52183. }
  52184. declare module BABYLON {
  52185. /** @hidden */
  52186. export var geometryPixelShader: {
  52187. name: string;
  52188. shader: string;
  52189. };
  52190. }
  52191. declare module BABYLON {
  52192. /** @hidden */
  52193. export var geometryVertexShader: {
  52194. name: string;
  52195. shader: string;
  52196. };
  52197. }
  52198. declare module BABYLON {
  52199. /**
  52200. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52201. */
  52202. export class GeometryBufferRenderer {
  52203. /**
  52204. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52205. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52206. */
  52207. static readonly POSITION_TEXTURE_TYPE: number;
  52208. /**
  52209. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52210. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52211. */
  52212. static readonly VELOCITY_TEXTURE_TYPE: number;
  52213. /**
  52214. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52215. * in order to compute objects velocities when enableVelocity is set to "true"
  52216. * @hidden
  52217. */ previousTransformationMatrices: {
  52218. [index: number]: Matrix;
  52219. };
  52220. private _scene;
  52221. private _multiRenderTarget;
  52222. private _ratio;
  52223. private _enablePosition;
  52224. private _enableVelocity;
  52225. private _positionIndex;
  52226. private _velocityIndex;
  52227. protected _effect: Effect;
  52228. protected _cachedDefines: string;
  52229. /**
  52230. * Set the render list (meshes to be rendered) used in the G buffer.
  52231. */
  52232. renderList: Mesh[];
  52233. /**
  52234. * Gets wether or not G buffer are supported by the running hardware.
  52235. * This requires draw buffer supports
  52236. */
  52237. readonly isSupported: boolean;
  52238. /**
  52239. * Returns the index of the given texture type in the G-Buffer textures array
  52240. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52241. * @returns the index of the given texture type in the G-Buffer textures array
  52242. */
  52243. getTextureIndex(textureType: number): number;
  52244. /**
  52245. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52246. */
  52247. /**
  52248. * Sets whether or not objects positions are enabled for the G buffer.
  52249. */
  52250. enablePosition: boolean;
  52251. /**
  52252. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52253. */
  52254. /**
  52255. * Sets wether or not objects velocities are enabled for the G buffer.
  52256. */
  52257. enableVelocity: boolean;
  52258. /**
  52259. * Gets the scene associated with the buffer.
  52260. */
  52261. readonly scene: Scene;
  52262. /**
  52263. * Gets the ratio used by the buffer during its creation.
  52264. * How big is the buffer related to the main canvas.
  52265. */
  52266. readonly ratio: number;
  52267. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  52268. /**
  52269. * Creates a new G Buffer for the scene
  52270. * @param scene The scene the buffer belongs to
  52271. * @param ratio How big is the buffer related to the main canvas.
  52272. */
  52273. constructor(scene: Scene, ratio?: number);
  52274. /**
  52275. * Checks wether everything is ready to render a submesh to the G buffer.
  52276. * @param subMesh the submesh to check readiness for
  52277. * @param useInstances is the mesh drawn using instance or not
  52278. * @returns true if ready otherwise false
  52279. */
  52280. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52281. /**
  52282. * Gets the current underlying G Buffer.
  52283. * @returns the buffer
  52284. */
  52285. getGBuffer(): MultiRenderTarget;
  52286. /**
  52287. * Gets the number of samples used to render the buffer (anti aliasing).
  52288. */
  52289. /**
  52290. * Sets the number of samples used to render the buffer (anti aliasing).
  52291. */
  52292. samples: number;
  52293. /**
  52294. * Disposes the renderer and frees up associated resources.
  52295. */
  52296. dispose(): void;
  52297. protected _createRenderTargets(): void;
  52298. }
  52299. }
  52300. declare module BABYLON {
  52301. interface Scene {
  52302. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52303. /**
  52304. * Gets or Sets the current geometry buffer associated to the scene.
  52305. */
  52306. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52307. /**
  52308. * Enables a GeometryBufferRender and associates it with the scene
  52309. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52310. * @returns the GeometryBufferRenderer
  52311. */
  52312. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52313. /**
  52314. * Disables the GeometryBufferRender associated with the scene
  52315. */
  52316. disableGeometryBufferRenderer(): void;
  52317. }
  52318. /**
  52319. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52320. * in several rendering techniques.
  52321. */
  52322. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52323. /**
  52324. * The component name helpful to identify the component in the list of scene components.
  52325. */
  52326. readonly name: string;
  52327. /**
  52328. * The scene the component belongs to.
  52329. */
  52330. scene: Scene;
  52331. /**
  52332. * Creates a new instance of the component for the given scene
  52333. * @param scene Defines the scene to register the component in
  52334. */
  52335. constructor(scene: Scene);
  52336. /**
  52337. * Registers the component in a given scene
  52338. */
  52339. register(): void;
  52340. /**
  52341. * Rebuilds the elements related to this component in case of
  52342. * context lost for instance.
  52343. */
  52344. rebuild(): void;
  52345. /**
  52346. * Disposes the component and the associated ressources
  52347. */
  52348. dispose(): void;
  52349. private _gatherRenderTargets;
  52350. }
  52351. }
  52352. declare module BABYLON {
  52353. /** @hidden */
  52354. export var motionBlurPixelShader: {
  52355. name: string;
  52356. shader: string;
  52357. };
  52358. }
  52359. declare module BABYLON {
  52360. /**
  52361. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52362. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52363. * As an example, all you have to do is to create the post-process:
  52364. * var mb = new BABYLON.MotionBlurPostProcess(
  52365. * 'mb', // The name of the effect.
  52366. * scene, // The scene containing the objects to blur according to their velocity.
  52367. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52368. * camera // The camera to apply the render pass to.
  52369. * );
  52370. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52371. */
  52372. export class MotionBlurPostProcess extends PostProcess {
  52373. /**
  52374. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52375. */
  52376. motionStrength: number;
  52377. /**
  52378. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52379. */
  52380. /**
  52381. * Sets the number of iterations to be used for motion blur quality
  52382. */
  52383. motionBlurSamples: number;
  52384. private _motionBlurSamples;
  52385. private _geometryBufferRenderer;
  52386. /**
  52387. * Creates a new instance MotionBlurPostProcess
  52388. * @param name The name of the effect.
  52389. * @param scene The scene containing the objects to blur according to their velocity.
  52390. * @param options The required width/height ratio to downsize to before computing the render pass.
  52391. * @param camera The camera to apply the render pass to.
  52392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52393. * @param engine The engine which the post process will be applied. (default: current engine)
  52394. * @param reusable If the post process can be reused on the same frame. (default: false)
  52395. * @param textureType Type of textures used when performing the post process. (default: 0)
  52396. * @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)
  52397. */
  52398. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52399. /**
  52400. * Disposes the post process.
  52401. * @param camera The camera to dispose the post process on.
  52402. */
  52403. dispose(camera?: Camera): void;
  52404. }
  52405. }
  52406. declare module BABYLON {
  52407. /** @hidden */
  52408. export var refractionPixelShader: {
  52409. name: string;
  52410. shader: string;
  52411. };
  52412. }
  52413. declare module BABYLON {
  52414. /**
  52415. * Post process which applies a refractin texture
  52416. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52417. */
  52418. export class RefractionPostProcess extends PostProcess {
  52419. /** the base color of the refraction (used to taint the rendering) */
  52420. color: Color3;
  52421. /** simulated refraction depth */
  52422. depth: number;
  52423. /** the coefficient of the base color (0 to remove base color tainting) */
  52424. colorLevel: number;
  52425. private _refTexture;
  52426. private _ownRefractionTexture;
  52427. /**
  52428. * Gets or sets the refraction texture
  52429. * Please note that you are responsible for disposing the texture if you set it manually
  52430. */
  52431. refractionTexture: Texture;
  52432. /**
  52433. * Initializes the RefractionPostProcess
  52434. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52435. * @param name The name of the effect.
  52436. * @param refractionTextureUrl Url of the refraction texture to use
  52437. * @param color the base color of the refraction (used to taint the rendering)
  52438. * @param depth simulated refraction depth
  52439. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52440. * @param camera The camera to apply the render pass to.
  52441. * @param options The required width/height ratio to downsize to before computing the render pass.
  52442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52443. * @param engine The engine which the post process will be applied. (default: current engine)
  52444. * @param reusable If the post process can be reused on the same frame. (default: false)
  52445. */
  52446. constructor(name: string, refractionTextureUrl: string,
  52447. /** the base color of the refraction (used to taint the rendering) */
  52448. color: Color3,
  52449. /** simulated refraction depth */
  52450. depth: number,
  52451. /** the coefficient of the base color (0 to remove base color tainting) */
  52452. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52453. /**
  52454. * Disposes of the post process
  52455. * @param camera Camera to dispose post process on
  52456. */
  52457. dispose(camera: Camera): void;
  52458. }
  52459. }
  52460. declare module BABYLON {
  52461. /** @hidden */
  52462. export var sharpenPixelShader: {
  52463. name: string;
  52464. shader: string;
  52465. };
  52466. }
  52467. declare module BABYLON {
  52468. /**
  52469. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52470. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52471. */
  52472. export class SharpenPostProcess extends PostProcess {
  52473. /**
  52474. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52475. */
  52476. colorAmount: number;
  52477. /**
  52478. * How much sharpness should be applied (default: 0.3)
  52479. */
  52480. edgeAmount: number;
  52481. /**
  52482. * Creates a new instance ConvolutionPostProcess
  52483. * @param name The name of the effect.
  52484. * @param options The required width/height ratio to downsize to before computing the render pass.
  52485. * @param camera The camera to apply the render pass to.
  52486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52487. * @param engine The engine which the post process will be applied. (default: current engine)
  52488. * @param reusable If the post process can be reused on the same frame. (default: false)
  52489. * @param textureType Type of textures used when performing the post process. (default: 0)
  52490. * @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)
  52491. */
  52492. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52493. }
  52494. }
  52495. declare module BABYLON {
  52496. /**
  52497. * PostProcessRenderPipeline
  52498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52499. */
  52500. export class PostProcessRenderPipeline {
  52501. private engine;
  52502. private _renderEffects;
  52503. private _renderEffectsForIsolatedPass;
  52504. /**
  52505. * List of inspectable custom properties (used by the Inspector)
  52506. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52507. */
  52508. inspectableCustomProperties: IInspectable[];
  52509. /**
  52510. * @hidden
  52511. */
  52512. protected _cameras: Camera[];
  52513. /** @hidden */ name: string;
  52514. /**
  52515. * Gets pipeline name
  52516. */
  52517. readonly name: string;
  52518. /**
  52519. * Initializes a PostProcessRenderPipeline
  52520. * @param engine engine to add the pipeline to
  52521. * @param name name of the pipeline
  52522. */
  52523. constructor(engine: Engine, name: string);
  52524. /**
  52525. * Gets the class name
  52526. * @returns "PostProcessRenderPipeline"
  52527. */
  52528. getClassName(): string;
  52529. /**
  52530. * If all the render effects in the pipeline are supported
  52531. */
  52532. readonly isSupported: boolean;
  52533. /**
  52534. * Adds an effect to the pipeline
  52535. * @param renderEffect the effect to add
  52536. */
  52537. addEffect(renderEffect: PostProcessRenderEffect): void;
  52538. /** @hidden */ rebuild(): void;
  52539. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  52540. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52541. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52542. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52543. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  52544. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  52545. /** @hidden */ detachCameras(cameras: Camera): void;
  52546. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  52547. /** @hidden */ update(): void;
  52548. /** @hidden */ reset(): void;
  52549. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52550. /**
  52551. * Disposes of the pipeline
  52552. */
  52553. dispose(): void;
  52554. }
  52555. }
  52556. declare module BABYLON {
  52557. /**
  52558. * PostProcessRenderPipelineManager class
  52559. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52560. */
  52561. export class PostProcessRenderPipelineManager {
  52562. private _renderPipelines;
  52563. /**
  52564. * Initializes a PostProcessRenderPipelineManager
  52565. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52566. */
  52567. constructor();
  52568. /**
  52569. * Gets the list of supported render pipelines
  52570. */
  52571. readonly supportedPipelines: PostProcessRenderPipeline[];
  52572. /**
  52573. * Adds a pipeline to the manager
  52574. * @param renderPipeline The pipeline to add
  52575. */
  52576. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52577. /**
  52578. * Attaches a camera to the pipeline
  52579. * @param renderPipelineName The name of the pipeline to attach to
  52580. * @param cameras the camera to attach
  52581. * @param unique if the camera can be attached multiple times to the pipeline
  52582. */
  52583. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52584. /**
  52585. * Detaches a camera from the pipeline
  52586. * @param renderPipelineName The name of the pipeline to detach from
  52587. * @param cameras the camera to detach
  52588. */
  52589. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52590. /**
  52591. * Enables an effect by name on a pipeline
  52592. * @param renderPipelineName the name of the pipeline to enable the effect in
  52593. * @param renderEffectName the name of the effect to enable
  52594. * @param cameras the cameras that the effect should be enabled on
  52595. */
  52596. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52597. /**
  52598. * Disables an effect by name on a pipeline
  52599. * @param renderPipelineName the name of the pipeline to disable the effect in
  52600. * @param renderEffectName the name of the effect to disable
  52601. * @param cameras the cameras that the effect should be disabled on
  52602. */
  52603. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52604. /**
  52605. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52606. */
  52607. update(): void;
  52608. /** @hidden */ rebuild(): void;
  52609. /**
  52610. * Disposes of the manager and pipelines
  52611. */
  52612. dispose(): void;
  52613. }
  52614. }
  52615. declare module BABYLON {
  52616. interface Scene {
  52617. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52618. /**
  52619. * Gets the postprocess render pipeline manager
  52620. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52621. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52622. */
  52623. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52624. }
  52625. /**
  52626. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52627. */
  52628. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52629. /**
  52630. * The component name helpfull to identify the component in the list of scene components.
  52631. */
  52632. readonly name: string;
  52633. /**
  52634. * The scene the component belongs to.
  52635. */
  52636. scene: Scene;
  52637. /**
  52638. * Creates a new instance of the component for the given scene
  52639. * @param scene Defines the scene to register the component in
  52640. */
  52641. constructor(scene: Scene);
  52642. /**
  52643. * Registers the component in a given scene
  52644. */
  52645. register(): void;
  52646. /**
  52647. * Rebuilds the elements related to this component in case of
  52648. * context lost for instance.
  52649. */
  52650. rebuild(): void;
  52651. /**
  52652. * Disposes the component and the associated ressources
  52653. */
  52654. dispose(): void;
  52655. private _gatherRenderTargets;
  52656. }
  52657. }
  52658. declare module BABYLON {
  52659. /**
  52660. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52661. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52662. */
  52663. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52664. private _scene;
  52665. private _camerasToBeAttached;
  52666. /**
  52667. * ID of the sharpen post process,
  52668. */
  52669. private readonly SharpenPostProcessId;
  52670. /**
  52671. * @ignore
  52672. * ID of the image processing post process;
  52673. */
  52674. readonly ImageProcessingPostProcessId: string;
  52675. /**
  52676. * @ignore
  52677. * ID of the Fast Approximate Anti-Aliasing post process;
  52678. */
  52679. readonly FxaaPostProcessId: string;
  52680. /**
  52681. * ID of the chromatic aberration post process,
  52682. */
  52683. private readonly ChromaticAberrationPostProcessId;
  52684. /**
  52685. * ID of the grain post process
  52686. */
  52687. private readonly GrainPostProcessId;
  52688. /**
  52689. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52690. */
  52691. sharpen: SharpenPostProcess;
  52692. private _sharpenEffect;
  52693. private bloom;
  52694. /**
  52695. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52696. */
  52697. depthOfField: DepthOfFieldEffect;
  52698. /**
  52699. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52700. */
  52701. fxaa: FxaaPostProcess;
  52702. /**
  52703. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52704. */
  52705. imageProcessing: ImageProcessingPostProcess;
  52706. /**
  52707. * Chromatic aberration post process which will shift rgb colors in the image
  52708. */
  52709. chromaticAberration: ChromaticAberrationPostProcess;
  52710. private _chromaticAberrationEffect;
  52711. /**
  52712. * Grain post process which add noise to the image
  52713. */
  52714. grain: GrainPostProcess;
  52715. private _grainEffect;
  52716. /**
  52717. * Glow post process which adds a glow to emissive areas of the image
  52718. */
  52719. private _glowLayer;
  52720. /**
  52721. * Animations which can be used to tweak settings over a period of time
  52722. */
  52723. animations: Animation[];
  52724. private _imageProcessingConfigurationObserver;
  52725. private _sharpenEnabled;
  52726. private _bloomEnabled;
  52727. private _depthOfFieldEnabled;
  52728. private _depthOfFieldBlurLevel;
  52729. private _fxaaEnabled;
  52730. private _imageProcessingEnabled;
  52731. private _defaultPipelineTextureType;
  52732. private _bloomScale;
  52733. private _chromaticAberrationEnabled;
  52734. private _grainEnabled;
  52735. private _buildAllowed;
  52736. /**
  52737. * Gets active scene
  52738. */
  52739. readonly scene: Scene;
  52740. /**
  52741. * Enable or disable the sharpen process from the pipeline
  52742. */
  52743. sharpenEnabled: boolean;
  52744. private _resizeObserver;
  52745. private _hardwareScaleLevel;
  52746. private _bloomKernel;
  52747. /**
  52748. * Specifies the size of the bloom blur kernel, relative to the final output size
  52749. */
  52750. bloomKernel: number;
  52751. /**
  52752. * Specifies the weight of the bloom in the final rendering
  52753. */
  52754. private _bloomWeight;
  52755. /**
  52756. * Specifies the luma threshold for the area that will be blurred by the bloom
  52757. */
  52758. private _bloomThreshold;
  52759. private _hdr;
  52760. /**
  52761. * The strength of the bloom.
  52762. */
  52763. bloomWeight: number;
  52764. /**
  52765. * The strength of the bloom.
  52766. */
  52767. bloomThreshold: number;
  52768. /**
  52769. * The scale of the bloom, lower value will provide better performance.
  52770. */
  52771. bloomScale: number;
  52772. /**
  52773. * Enable or disable the bloom from the pipeline
  52774. */
  52775. bloomEnabled: boolean;
  52776. private _rebuildBloom;
  52777. /**
  52778. * If the depth of field is enabled.
  52779. */
  52780. depthOfFieldEnabled: boolean;
  52781. /**
  52782. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52783. */
  52784. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52785. /**
  52786. * If the anti aliasing is enabled.
  52787. */
  52788. fxaaEnabled: boolean;
  52789. private _samples;
  52790. /**
  52791. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52792. */
  52793. samples: number;
  52794. /**
  52795. * If image processing is enabled.
  52796. */
  52797. imageProcessingEnabled: boolean;
  52798. /**
  52799. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52800. */
  52801. glowLayerEnabled: boolean;
  52802. /**
  52803. * Enable or disable the chromaticAberration process from the pipeline
  52804. */
  52805. chromaticAberrationEnabled: boolean;
  52806. /**
  52807. * Enable or disable the grain process from the pipeline
  52808. */
  52809. grainEnabled: boolean;
  52810. /**
  52811. * @constructor
  52812. * @param name - The rendering pipeline name (default: "")
  52813. * @param hdr - If high dynamic range textures should be used (default: true)
  52814. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52815. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52816. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52817. */
  52818. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52819. /**
  52820. * Get the class name
  52821. * @returns "DefaultRenderingPipeline"
  52822. */
  52823. getClassName(): string;
  52824. /**
  52825. * Force the compilation of the entire pipeline.
  52826. */
  52827. prepare(): void;
  52828. private _hasCleared;
  52829. private _prevPostProcess;
  52830. private _prevPrevPostProcess;
  52831. private _setAutoClearAndTextureSharing;
  52832. private _depthOfFieldSceneObserver;
  52833. private _buildPipeline;
  52834. private _disposePostProcesses;
  52835. /**
  52836. * Adds a camera to the pipeline
  52837. * @param camera the camera to be added
  52838. */
  52839. addCamera(camera: Camera): void;
  52840. /**
  52841. * Removes a camera from the pipeline
  52842. * @param camera the camera to remove
  52843. */
  52844. removeCamera(camera: Camera): void;
  52845. /**
  52846. * Dispose of the pipeline and stop all post processes
  52847. */
  52848. dispose(): void;
  52849. /**
  52850. * Serialize the rendering pipeline (Used when exporting)
  52851. * @returns the serialized object
  52852. */
  52853. serialize(): any;
  52854. /**
  52855. * Parse the serialized pipeline
  52856. * @param source Source pipeline.
  52857. * @param scene The scene to load the pipeline to.
  52858. * @param rootUrl The URL of the serialized pipeline.
  52859. * @returns An instantiated pipeline from the serialized object.
  52860. */
  52861. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52862. }
  52863. }
  52864. declare module BABYLON {
  52865. /** @hidden */
  52866. export var lensHighlightsPixelShader: {
  52867. name: string;
  52868. shader: string;
  52869. };
  52870. }
  52871. declare module BABYLON {
  52872. /** @hidden */
  52873. export var depthOfFieldPixelShader: {
  52874. name: string;
  52875. shader: string;
  52876. };
  52877. }
  52878. declare module BABYLON {
  52879. /**
  52880. * BABYLON.JS Chromatic Aberration GLSL Shader
  52881. * Author: Olivier Guyot
  52882. * Separates very slightly R, G and B colors on the edges of the screen
  52883. * Inspired by Francois Tarlier & Martins Upitis
  52884. */
  52885. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52886. /**
  52887. * @ignore
  52888. * The chromatic aberration PostProcess id in the pipeline
  52889. */
  52890. LensChromaticAberrationEffect: string;
  52891. /**
  52892. * @ignore
  52893. * The highlights enhancing PostProcess id in the pipeline
  52894. */
  52895. HighlightsEnhancingEffect: string;
  52896. /**
  52897. * @ignore
  52898. * The depth-of-field PostProcess id in the pipeline
  52899. */
  52900. LensDepthOfFieldEffect: string;
  52901. private _scene;
  52902. private _depthTexture;
  52903. private _grainTexture;
  52904. private _chromaticAberrationPostProcess;
  52905. private _highlightsPostProcess;
  52906. private _depthOfFieldPostProcess;
  52907. private _edgeBlur;
  52908. private _grainAmount;
  52909. private _chromaticAberration;
  52910. private _distortion;
  52911. private _highlightsGain;
  52912. private _highlightsThreshold;
  52913. private _dofDistance;
  52914. private _dofAperture;
  52915. private _dofDarken;
  52916. private _dofPentagon;
  52917. private _blurNoise;
  52918. /**
  52919. * @constructor
  52920. *
  52921. * Effect parameters are as follow:
  52922. * {
  52923. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52924. * edge_blur: number; // from 0 to x (1 for realism)
  52925. * distortion: number; // from 0 to x (1 for realism)
  52926. * grain_amount: number; // from 0 to 1
  52927. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52928. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52929. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52930. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52931. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52932. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52933. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52934. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52935. * }
  52936. * Note: if an effect parameter is unset, effect is disabled
  52937. *
  52938. * @param name The rendering pipeline name
  52939. * @param parameters - An object containing all parameters (see above)
  52940. * @param scene The scene linked to this pipeline
  52941. * @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)
  52942. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52943. */
  52944. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52945. /**
  52946. * Get the class name
  52947. * @returns "LensRenderingPipeline"
  52948. */
  52949. getClassName(): string;
  52950. /**
  52951. * Gets associated scene
  52952. */
  52953. readonly scene: Scene;
  52954. /**
  52955. * Gets or sets the edge blur
  52956. */
  52957. edgeBlur: number;
  52958. /**
  52959. * Gets or sets the grain amount
  52960. */
  52961. grainAmount: number;
  52962. /**
  52963. * Gets or sets the chromatic aberration amount
  52964. */
  52965. chromaticAberration: number;
  52966. /**
  52967. * Gets or sets the depth of field aperture
  52968. */
  52969. dofAperture: number;
  52970. /**
  52971. * Gets or sets the edge distortion
  52972. */
  52973. edgeDistortion: number;
  52974. /**
  52975. * Gets or sets the depth of field distortion
  52976. */
  52977. dofDistortion: number;
  52978. /**
  52979. * Gets or sets the darken out of focus amount
  52980. */
  52981. darkenOutOfFocus: number;
  52982. /**
  52983. * Gets or sets a boolean indicating if blur noise is enabled
  52984. */
  52985. blurNoise: boolean;
  52986. /**
  52987. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  52988. */
  52989. pentagonBokeh: boolean;
  52990. /**
  52991. * Gets or sets the highlight grain amount
  52992. */
  52993. highlightsGain: number;
  52994. /**
  52995. * Gets or sets the highlight threshold
  52996. */
  52997. highlightsThreshold: number;
  52998. /**
  52999. * Sets the amount of blur at the edges
  53000. * @param amount blur amount
  53001. */
  53002. setEdgeBlur(amount: number): void;
  53003. /**
  53004. * Sets edge blur to 0
  53005. */
  53006. disableEdgeBlur(): void;
  53007. /**
  53008. * Sets the amout of grain
  53009. * @param amount Amount of grain
  53010. */
  53011. setGrainAmount(amount: number): void;
  53012. /**
  53013. * Set grain amount to 0
  53014. */
  53015. disableGrain(): void;
  53016. /**
  53017. * Sets the chromatic aberration amount
  53018. * @param amount amount of chromatic aberration
  53019. */
  53020. setChromaticAberration(amount: number): void;
  53021. /**
  53022. * Sets chromatic aberration amount to 0
  53023. */
  53024. disableChromaticAberration(): void;
  53025. /**
  53026. * Sets the EdgeDistortion amount
  53027. * @param amount amount of EdgeDistortion
  53028. */
  53029. setEdgeDistortion(amount: number): void;
  53030. /**
  53031. * Sets edge distortion to 0
  53032. */
  53033. disableEdgeDistortion(): void;
  53034. /**
  53035. * Sets the FocusDistance amount
  53036. * @param amount amount of FocusDistance
  53037. */
  53038. setFocusDistance(amount: number): void;
  53039. /**
  53040. * Disables depth of field
  53041. */
  53042. disableDepthOfField(): void;
  53043. /**
  53044. * Sets the Aperture amount
  53045. * @param amount amount of Aperture
  53046. */
  53047. setAperture(amount: number): void;
  53048. /**
  53049. * Sets the DarkenOutOfFocus amount
  53050. * @param amount amount of DarkenOutOfFocus
  53051. */
  53052. setDarkenOutOfFocus(amount: number): void;
  53053. private _pentagonBokehIsEnabled;
  53054. /**
  53055. * Creates a pentagon bokeh effect
  53056. */
  53057. enablePentagonBokeh(): void;
  53058. /**
  53059. * Disables the pentagon bokeh effect
  53060. */
  53061. disablePentagonBokeh(): void;
  53062. /**
  53063. * Enables noise blur
  53064. */
  53065. enableNoiseBlur(): void;
  53066. /**
  53067. * Disables noise blur
  53068. */
  53069. disableNoiseBlur(): void;
  53070. /**
  53071. * Sets the HighlightsGain amount
  53072. * @param amount amount of HighlightsGain
  53073. */
  53074. setHighlightsGain(amount: number): void;
  53075. /**
  53076. * Sets the HighlightsThreshold amount
  53077. * @param amount amount of HighlightsThreshold
  53078. */
  53079. setHighlightsThreshold(amount: number): void;
  53080. /**
  53081. * Disables highlights
  53082. */
  53083. disableHighlights(): void;
  53084. /**
  53085. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53086. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53087. */
  53088. dispose(disableDepthRender?: boolean): void;
  53089. private _createChromaticAberrationPostProcess;
  53090. private _createHighlightsPostProcess;
  53091. private _createDepthOfFieldPostProcess;
  53092. private _createGrainTexture;
  53093. }
  53094. }
  53095. declare module BABYLON {
  53096. /** @hidden */
  53097. export var ssao2PixelShader: {
  53098. name: string;
  53099. shader: string;
  53100. };
  53101. }
  53102. declare module BABYLON {
  53103. /** @hidden */
  53104. export var ssaoCombinePixelShader: {
  53105. name: string;
  53106. shader: string;
  53107. };
  53108. }
  53109. declare module BABYLON {
  53110. /**
  53111. * Render pipeline to produce ssao effect
  53112. */
  53113. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53114. /**
  53115. * @ignore
  53116. * The PassPostProcess id in the pipeline that contains the original scene color
  53117. */
  53118. SSAOOriginalSceneColorEffect: string;
  53119. /**
  53120. * @ignore
  53121. * The SSAO PostProcess id in the pipeline
  53122. */
  53123. SSAORenderEffect: string;
  53124. /**
  53125. * @ignore
  53126. * The horizontal blur PostProcess id in the pipeline
  53127. */
  53128. SSAOBlurHRenderEffect: string;
  53129. /**
  53130. * @ignore
  53131. * The vertical blur PostProcess id in the pipeline
  53132. */
  53133. SSAOBlurVRenderEffect: string;
  53134. /**
  53135. * @ignore
  53136. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53137. */
  53138. SSAOCombineRenderEffect: string;
  53139. /**
  53140. * The output strength of the SSAO post-process. Default value is 1.0.
  53141. */
  53142. totalStrength: number;
  53143. /**
  53144. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53145. */
  53146. maxZ: number;
  53147. /**
  53148. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53149. */
  53150. minZAspect: number;
  53151. private _samples;
  53152. /**
  53153. * Number of samples used for the SSAO calculations. Default value is 8
  53154. */
  53155. samples: number;
  53156. private _textureSamples;
  53157. /**
  53158. * Number of samples to use for antialiasing
  53159. */
  53160. textureSamples: number;
  53161. /**
  53162. * Ratio object used for SSAO ratio and blur ratio
  53163. */
  53164. private _ratio;
  53165. /**
  53166. * Dynamically generated sphere sampler.
  53167. */
  53168. private _sampleSphere;
  53169. /**
  53170. * Blur filter offsets
  53171. */
  53172. private _samplerOffsets;
  53173. private _expensiveBlur;
  53174. /**
  53175. * If bilateral blur should be used
  53176. */
  53177. expensiveBlur: boolean;
  53178. /**
  53179. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53180. */
  53181. radius: number;
  53182. /**
  53183. * The base color of the SSAO post-process
  53184. * The final result is "base + ssao" between [0, 1]
  53185. */
  53186. base: number;
  53187. /**
  53188. * Support test.
  53189. */
  53190. static readonly IsSupported: boolean;
  53191. private _scene;
  53192. private _depthTexture;
  53193. private _normalTexture;
  53194. private _randomTexture;
  53195. private _originalColorPostProcess;
  53196. private _ssaoPostProcess;
  53197. private _blurHPostProcess;
  53198. private _blurVPostProcess;
  53199. private _ssaoCombinePostProcess;
  53200. private _firstUpdate;
  53201. /**
  53202. * Gets active scene
  53203. */
  53204. readonly scene: Scene;
  53205. /**
  53206. * @constructor
  53207. * @param name The rendering pipeline name
  53208. * @param scene The scene linked to this pipeline
  53209. * @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 }
  53210. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53211. */
  53212. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53213. /**
  53214. * Get the class name
  53215. * @returns "SSAO2RenderingPipeline"
  53216. */
  53217. getClassName(): string;
  53218. /**
  53219. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53220. */
  53221. dispose(disableGeometryBufferRenderer?: boolean): void;
  53222. private _createBlurPostProcess;
  53223. /** @hidden */ rebuild(): void;
  53224. private _bits;
  53225. private _radicalInverse_VdC;
  53226. private _hammersley;
  53227. private _hemisphereSample_uniform;
  53228. private _generateHemisphere;
  53229. private _createSSAOPostProcess;
  53230. private _createSSAOCombinePostProcess;
  53231. private _createRandomTexture;
  53232. /**
  53233. * Serialize the rendering pipeline (Used when exporting)
  53234. * @returns the serialized object
  53235. */
  53236. serialize(): any;
  53237. /**
  53238. * Parse the serialized pipeline
  53239. * @param source Source pipeline.
  53240. * @param scene The scene to load the pipeline to.
  53241. * @param rootUrl The URL of the serialized pipeline.
  53242. * @returns An instantiated pipeline from the serialized object.
  53243. */
  53244. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53245. }
  53246. }
  53247. declare module BABYLON {
  53248. /** @hidden */
  53249. export var ssaoPixelShader: {
  53250. name: string;
  53251. shader: string;
  53252. };
  53253. }
  53254. declare module BABYLON {
  53255. /**
  53256. * Render pipeline to produce ssao effect
  53257. */
  53258. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53259. /**
  53260. * @ignore
  53261. * The PassPostProcess id in the pipeline that contains the original scene color
  53262. */
  53263. SSAOOriginalSceneColorEffect: string;
  53264. /**
  53265. * @ignore
  53266. * The SSAO PostProcess id in the pipeline
  53267. */
  53268. SSAORenderEffect: string;
  53269. /**
  53270. * @ignore
  53271. * The horizontal blur PostProcess id in the pipeline
  53272. */
  53273. SSAOBlurHRenderEffect: string;
  53274. /**
  53275. * @ignore
  53276. * The vertical blur PostProcess id in the pipeline
  53277. */
  53278. SSAOBlurVRenderEffect: string;
  53279. /**
  53280. * @ignore
  53281. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53282. */
  53283. SSAOCombineRenderEffect: string;
  53284. /**
  53285. * The output strength of the SSAO post-process. Default value is 1.0.
  53286. */
  53287. totalStrength: number;
  53288. /**
  53289. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53290. */
  53291. radius: number;
  53292. /**
  53293. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53294. * Must not be equal to fallOff and superior to fallOff.
  53295. * Default value is 0.0075
  53296. */
  53297. area: number;
  53298. /**
  53299. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53300. * Must not be equal to area and inferior to area.
  53301. * Default value is 0.000001
  53302. */
  53303. fallOff: number;
  53304. /**
  53305. * The base color of the SSAO post-process
  53306. * The final result is "base + ssao" between [0, 1]
  53307. */
  53308. base: number;
  53309. private _scene;
  53310. private _depthTexture;
  53311. private _randomTexture;
  53312. private _originalColorPostProcess;
  53313. private _ssaoPostProcess;
  53314. private _blurHPostProcess;
  53315. private _blurVPostProcess;
  53316. private _ssaoCombinePostProcess;
  53317. private _firstUpdate;
  53318. /**
  53319. * Gets active scene
  53320. */
  53321. readonly scene: Scene;
  53322. /**
  53323. * @constructor
  53324. * @param name - The rendering pipeline name
  53325. * @param scene - The scene linked to this pipeline
  53326. * @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 }
  53327. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53328. */
  53329. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53330. /**
  53331. * Get the class name
  53332. * @returns "SSAORenderingPipeline"
  53333. */
  53334. getClassName(): string;
  53335. /**
  53336. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53337. */
  53338. dispose(disableDepthRender?: boolean): void;
  53339. private _createBlurPostProcess;
  53340. /** @hidden */ rebuild(): void;
  53341. private _createSSAOPostProcess;
  53342. private _createSSAOCombinePostProcess;
  53343. private _createRandomTexture;
  53344. }
  53345. }
  53346. declare module BABYLON {
  53347. /** @hidden */
  53348. export var standardPixelShader: {
  53349. name: string;
  53350. shader: string;
  53351. };
  53352. }
  53353. declare module BABYLON {
  53354. /**
  53355. * Standard rendering pipeline
  53356. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53357. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53358. */
  53359. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53360. /**
  53361. * Public members
  53362. */
  53363. /**
  53364. * Post-process which contains the original scene color before the pipeline applies all the effects
  53365. */
  53366. originalPostProcess: Nullable<PostProcess>;
  53367. /**
  53368. * Post-process used to down scale an image x4
  53369. */
  53370. downSampleX4PostProcess: Nullable<PostProcess>;
  53371. /**
  53372. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53373. */
  53374. brightPassPostProcess: Nullable<PostProcess>;
  53375. /**
  53376. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53377. */
  53378. blurHPostProcesses: PostProcess[];
  53379. /**
  53380. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53381. */
  53382. blurVPostProcesses: PostProcess[];
  53383. /**
  53384. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53385. */
  53386. textureAdderPostProcess: Nullable<PostProcess>;
  53387. /**
  53388. * Post-process used to create volumetric lighting effect
  53389. */
  53390. volumetricLightPostProcess: Nullable<PostProcess>;
  53391. /**
  53392. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53393. */
  53394. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53395. /**
  53396. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53397. */
  53398. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53399. /**
  53400. * Post-process used to merge the volumetric light effect and the real scene color
  53401. */
  53402. volumetricLightMergePostProces: Nullable<PostProcess>;
  53403. /**
  53404. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53405. */
  53406. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53407. /**
  53408. * Base post-process used to calculate the average luminance of the final image for HDR
  53409. */
  53410. luminancePostProcess: Nullable<PostProcess>;
  53411. /**
  53412. * Post-processes used to create down sample post-processes in order to get
  53413. * the average luminance of the final image for HDR
  53414. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53415. */
  53416. luminanceDownSamplePostProcesses: PostProcess[];
  53417. /**
  53418. * Post-process used to create a HDR effect (light adaptation)
  53419. */
  53420. hdrPostProcess: Nullable<PostProcess>;
  53421. /**
  53422. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53423. */
  53424. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53425. /**
  53426. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53427. */
  53428. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53429. /**
  53430. * Post-process used to merge the final HDR post-process and the real scene color
  53431. */
  53432. hdrFinalPostProcess: Nullable<PostProcess>;
  53433. /**
  53434. * Post-process used to create a lens flare effect
  53435. */
  53436. lensFlarePostProcess: Nullable<PostProcess>;
  53437. /**
  53438. * Post-process that merges the result of the lens flare post-process and the real scene color
  53439. */
  53440. lensFlareComposePostProcess: Nullable<PostProcess>;
  53441. /**
  53442. * Post-process used to create a motion blur effect
  53443. */
  53444. motionBlurPostProcess: Nullable<PostProcess>;
  53445. /**
  53446. * Post-process used to create a depth of field effect
  53447. */
  53448. depthOfFieldPostProcess: Nullable<PostProcess>;
  53449. /**
  53450. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53451. */
  53452. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53453. /**
  53454. * Represents the brightness threshold in order to configure the illuminated surfaces
  53455. */
  53456. brightThreshold: number;
  53457. /**
  53458. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53459. */
  53460. blurWidth: number;
  53461. /**
  53462. * Sets if the blur for highlighted surfaces must be only horizontal
  53463. */
  53464. horizontalBlur: boolean;
  53465. /**
  53466. * Gets the overall exposure used by the pipeline
  53467. */
  53468. /**
  53469. * Sets the overall exposure used by the pipeline
  53470. */
  53471. exposure: number;
  53472. /**
  53473. * Texture used typically to simulate "dirty" on camera lens
  53474. */
  53475. lensTexture: Nullable<Texture>;
  53476. /**
  53477. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53478. */
  53479. volumetricLightCoefficient: number;
  53480. /**
  53481. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53482. */
  53483. volumetricLightPower: number;
  53484. /**
  53485. * Used the set the blur intensity to smooth the volumetric lights
  53486. */
  53487. volumetricLightBlurScale: number;
  53488. /**
  53489. * Light (spot or directional) used to generate the volumetric lights rays
  53490. * The source light must have a shadow generate so the pipeline can get its
  53491. * depth map
  53492. */
  53493. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53494. /**
  53495. * For eye adaptation, represents the minimum luminance the eye can see
  53496. */
  53497. hdrMinimumLuminance: number;
  53498. /**
  53499. * For eye adaptation, represents the decrease luminance speed
  53500. */
  53501. hdrDecreaseRate: number;
  53502. /**
  53503. * For eye adaptation, represents the increase luminance speed
  53504. */
  53505. hdrIncreaseRate: number;
  53506. /**
  53507. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53508. */
  53509. /**
  53510. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53511. */
  53512. hdrAutoExposure: boolean;
  53513. /**
  53514. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53515. */
  53516. lensColorTexture: Nullable<Texture>;
  53517. /**
  53518. * The overall strengh for the lens flare effect
  53519. */
  53520. lensFlareStrength: number;
  53521. /**
  53522. * Dispersion coefficient for lens flare ghosts
  53523. */
  53524. lensFlareGhostDispersal: number;
  53525. /**
  53526. * Main lens flare halo width
  53527. */
  53528. lensFlareHaloWidth: number;
  53529. /**
  53530. * Based on the lens distortion effect, defines how much the lens flare result
  53531. * is distorted
  53532. */
  53533. lensFlareDistortionStrength: number;
  53534. /**
  53535. * Lens star texture must be used to simulate rays on the flares and is available
  53536. * in the documentation
  53537. */
  53538. lensStarTexture: Nullable<Texture>;
  53539. /**
  53540. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53541. * flare effect by taking account of the dirt texture
  53542. */
  53543. lensFlareDirtTexture: Nullable<Texture>;
  53544. /**
  53545. * Represents the focal length for the depth of field effect
  53546. */
  53547. depthOfFieldDistance: number;
  53548. /**
  53549. * Represents the blur intensity for the blurred part of the depth of field effect
  53550. */
  53551. depthOfFieldBlurWidth: number;
  53552. /**
  53553. * For motion blur, defines how much the image is blurred by the movement
  53554. */
  53555. motionStrength: number;
  53556. /**
  53557. * List of animations for the pipeline (IAnimatable implementation)
  53558. */
  53559. animations: Animation[];
  53560. /**
  53561. * Private members
  53562. */
  53563. private _scene;
  53564. private _currentDepthOfFieldSource;
  53565. private _basePostProcess;
  53566. private _fixedExposure;
  53567. private _currentExposure;
  53568. private _hdrAutoExposure;
  53569. private _hdrCurrentLuminance;
  53570. private _floatTextureType;
  53571. private _ratio;
  53572. private _bloomEnabled;
  53573. private _depthOfFieldEnabled;
  53574. private _vlsEnabled;
  53575. private _lensFlareEnabled;
  53576. private _hdrEnabled;
  53577. private _motionBlurEnabled;
  53578. private _fxaaEnabled;
  53579. private _motionBlurSamples;
  53580. private _volumetricLightStepsCount;
  53581. private _samples;
  53582. /**
  53583. * @ignore
  53584. * Specifies if the bloom pipeline is enabled
  53585. */
  53586. BloomEnabled: boolean;
  53587. /**
  53588. * @ignore
  53589. * Specifies if the depth of field pipeline is enabed
  53590. */
  53591. DepthOfFieldEnabled: boolean;
  53592. /**
  53593. * @ignore
  53594. * Specifies if the lens flare pipeline is enabed
  53595. */
  53596. LensFlareEnabled: boolean;
  53597. /**
  53598. * @ignore
  53599. * Specifies if the HDR pipeline is enabled
  53600. */
  53601. HDREnabled: boolean;
  53602. /**
  53603. * @ignore
  53604. * Specifies if the volumetric lights scattering effect is enabled
  53605. */
  53606. VLSEnabled: boolean;
  53607. /**
  53608. * @ignore
  53609. * Specifies if the motion blur effect is enabled
  53610. */
  53611. MotionBlurEnabled: boolean;
  53612. /**
  53613. * Specifies if anti-aliasing is enabled
  53614. */
  53615. fxaaEnabled: boolean;
  53616. /**
  53617. * Specifies the number of steps used to calculate the volumetric lights
  53618. * Typically in interval [50, 200]
  53619. */
  53620. volumetricLightStepsCount: number;
  53621. /**
  53622. * Specifies the number of samples used for the motion blur effect
  53623. * Typically in interval [16, 64]
  53624. */
  53625. motionBlurSamples: number;
  53626. /**
  53627. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53628. */
  53629. samples: number;
  53630. /**
  53631. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53632. * @constructor
  53633. * @param name The rendering pipeline name
  53634. * @param scene The scene linked to this pipeline
  53635. * @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)
  53636. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53637. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53638. */
  53639. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53640. private _buildPipeline;
  53641. private _createDownSampleX4PostProcess;
  53642. private _createBrightPassPostProcess;
  53643. private _createBlurPostProcesses;
  53644. private _createTextureAdderPostProcess;
  53645. private _createVolumetricLightPostProcess;
  53646. private _createLuminancePostProcesses;
  53647. private _createHdrPostProcess;
  53648. private _createLensFlarePostProcess;
  53649. private _createDepthOfFieldPostProcess;
  53650. private _createMotionBlurPostProcess;
  53651. private _getDepthTexture;
  53652. private _disposePostProcesses;
  53653. /**
  53654. * Dispose of the pipeline and stop all post processes
  53655. */
  53656. dispose(): void;
  53657. /**
  53658. * Serialize the rendering pipeline (Used when exporting)
  53659. * @returns the serialized object
  53660. */
  53661. serialize(): any;
  53662. /**
  53663. * Parse the serialized pipeline
  53664. * @param source Source pipeline.
  53665. * @param scene The scene to load the pipeline to.
  53666. * @param rootUrl The URL of the serialized pipeline.
  53667. * @returns An instantiated pipeline from the serialized object.
  53668. */
  53669. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53670. /**
  53671. * Luminance steps
  53672. */
  53673. static LuminanceSteps: number;
  53674. }
  53675. }
  53676. declare module BABYLON {
  53677. /** @hidden */
  53678. export var tonemapPixelShader: {
  53679. name: string;
  53680. shader: string;
  53681. };
  53682. }
  53683. declare module BABYLON {
  53684. /** Defines operator used for tonemapping */
  53685. export enum TonemappingOperator {
  53686. /** Hable */
  53687. Hable = 0,
  53688. /** Reinhard */
  53689. Reinhard = 1,
  53690. /** HejiDawson */
  53691. HejiDawson = 2,
  53692. /** Photographic */
  53693. Photographic = 3
  53694. }
  53695. /**
  53696. * Defines a post process to apply tone mapping
  53697. */
  53698. export class TonemapPostProcess extends PostProcess {
  53699. private _operator;
  53700. /** Defines the required exposure adjustement */
  53701. exposureAdjustment: number;
  53702. /**
  53703. * Creates a new TonemapPostProcess
  53704. * @param name defines the name of the postprocess
  53705. * @param _operator defines the operator to use
  53706. * @param exposureAdjustment defines the required exposure adjustement
  53707. * @param camera defines the camera to use (can be null)
  53708. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53709. * @param engine defines the hosting engine (can be ignore if camera is set)
  53710. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53711. */
  53712. constructor(name: string, _operator: TonemappingOperator,
  53713. /** Defines the required exposure adjustement */
  53714. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53715. }
  53716. }
  53717. declare module BABYLON {
  53718. /** @hidden */
  53719. export var depthVertexShader: {
  53720. name: string;
  53721. shader: string;
  53722. };
  53723. }
  53724. declare module BABYLON {
  53725. /** @hidden */
  53726. export var volumetricLightScatteringPixelShader: {
  53727. name: string;
  53728. shader: string;
  53729. };
  53730. }
  53731. declare module BABYLON {
  53732. /** @hidden */
  53733. export var volumetricLightScatteringPassPixelShader: {
  53734. name: string;
  53735. shader: string;
  53736. };
  53737. }
  53738. declare module BABYLON {
  53739. /**
  53740. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53741. */
  53742. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53743. private _volumetricLightScatteringPass;
  53744. private _volumetricLightScatteringRTT;
  53745. private _viewPort;
  53746. private _screenCoordinates;
  53747. private _cachedDefines;
  53748. /**
  53749. * If not undefined, the mesh position is computed from the attached node position
  53750. */
  53751. attachedNode: {
  53752. position: Vector3;
  53753. };
  53754. /**
  53755. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53756. */
  53757. customMeshPosition: Vector3;
  53758. /**
  53759. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53760. */
  53761. useCustomMeshPosition: boolean;
  53762. /**
  53763. * If the post-process should inverse the light scattering direction
  53764. */
  53765. invert: boolean;
  53766. /**
  53767. * The internal mesh used by the post-process
  53768. */
  53769. mesh: Mesh;
  53770. /**
  53771. * @hidden
  53772. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53773. */
  53774. useDiffuseColor: boolean;
  53775. /**
  53776. * Array containing the excluded meshes not rendered in the internal pass
  53777. */
  53778. excludedMeshes: AbstractMesh[];
  53779. /**
  53780. * Controls the overall intensity of the post-process
  53781. */
  53782. exposure: number;
  53783. /**
  53784. * Dissipates each sample's contribution in range [0, 1]
  53785. */
  53786. decay: number;
  53787. /**
  53788. * Controls the overall intensity of each sample
  53789. */
  53790. weight: number;
  53791. /**
  53792. * Controls the density of each sample
  53793. */
  53794. density: number;
  53795. /**
  53796. * @constructor
  53797. * @param name The post-process name
  53798. * @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)
  53799. * @param camera The camera that the post-process will be attached to
  53800. * @param mesh The mesh used to create the light scattering
  53801. * @param samples The post-process quality, default 100
  53802. * @param samplingModeThe post-process filtering mode
  53803. * @param engine The babylon engine
  53804. * @param reusable If the post-process is reusable
  53805. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53806. */
  53807. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53808. /**
  53809. * Returns the string "VolumetricLightScatteringPostProcess"
  53810. * @returns "VolumetricLightScatteringPostProcess"
  53811. */
  53812. getClassName(): string;
  53813. private _isReady;
  53814. /**
  53815. * Sets the new light position for light scattering effect
  53816. * @param position The new custom light position
  53817. */
  53818. setCustomMeshPosition(position: Vector3): void;
  53819. /**
  53820. * Returns the light position for light scattering effect
  53821. * @return Vector3 The custom light position
  53822. */
  53823. getCustomMeshPosition(): Vector3;
  53824. /**
  53825. * Disposes the internal assets and detaches the post-process from the camera
  53826. */
  53827. dispose(camera: Camera): void;
  53828. /**
  53829. * Returns the render target texture used by the post-process
  53830. * @return the render target texture used by the post-process
  53831. */
  53832. getPass(): RenderTargetTexture;
  53833. private _meshExcluded;
  53834. private _createPass;
  53835. private _updateMeshScreenCoordinates;
  53836. /**
  53837. * Creates a default mesh for the Volumeric Light Scattering post-process
  53838. * @param name The mesh name
  53839. * @param scene The scene where to create the mesh
  53840. * @return the default mesh
  53841. */
  53842. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53843. }
  53844. }
  53845. declare module BABYLON {
  53846. interface Scene {
  53847. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  53848. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  53849. /**
  53850. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53851. */
  53852. forceShowBoundingBoxes: boolean;
  53853. /**
  53854. * Gets the bounding box renderer associated with the scene
  53855. * @returns a BoundingBoxRenderer
  53856. */
  53857. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53858. }
  53859. interface AbstractMesh {
  53860. /** @hidden (Backing field) */ showBoundingBox: boolean;
  53861. /**
  53862. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53863. */
  53864. showBoundingBox: boolean;
  53865. }
  53866. /**
  53867. * Component responsible of rendering the bounding box of the meshes in a scene.
  53868. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53869. */
  53870. export class BoundingBoxRenderer implements ISceneComponent {
  53871. /**
  53872. * The component name helpfull to identify the component in the list of scene components.
  53873. */
  53874. readonly name: string;
  53875. /**
  53876. * The scene the component belongs to.
  53877. */
  53878. scene: Scene;
  53879. /**
  53880. * Color of the bounding box lines placed in front of an object
  53881. */
  53882. frontColor: Color3;
  53883. /**
  53884. * Color of the bounding box lines placed behind an object
  53885. */
  53886. backColor: Color3;
  53887. /**
  53888. * Defines if the renderer should show the back lines or not
  53889. */
  53890. showBackLines: boolean;
  53891. /**
  53892. * @hidden
  53893. */
  53894. renderList: SmartArray<BoundingBox>;
  53895. private _colorShader;
  53896. private _vertexBuffers;
  53897. private _indexBuffer;
  53898. /**
  53899. * Instantiates a new bounding box renderer in a scene.
  53900. * @param scene the scene the renderer renders in
  53901. */
  53902. constructor(scene: Scene);
  53903. /**
  53904. * Registers the component in a given scene
  53905. */
  53906. register(): void;
  53907. private _evaluateSubMesh;
  53908. private _activeMesh;
  53909. private _prepareRessources;
  53910. private _createIndexBuffer;
  53911. /**
  53912. * Rebuilds the elements related to this component in case of
  53913. * context lost for instance.
  53914. */
  53915. rebuild(): void;
  53916. /**
  53917. * @hidden
  53918. */
  53919. reset(): void;
  53920. /**
  53921. * Render the bounding boxes of a specific rendering group
  53922. * @param renderingGroupId defines the rendering group to render
  53923. */
  53924. render(renderingGroupId: number): void;
  53925. /**
  53926. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53927. * @param mesh Define the mesh to render the occlusion bounding box for
  53928. */
  53929. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53930. /**
  53931. * Dispose and release the resources attached to this renderer.
  53932. */
  53933. dispose(): void;
  53934. }
  53935. }
  53936. declare module BABYLON {
  53937. /** @hidden */
  53938. export var depthPixelShader: {
  53939. name: string;
  53940. shader: string;
  53941. };
  53942. }
  53943. declare module BABYLON {
  53944. /**
  53945. * This represents a depth renderer in Babylon.
  53946. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53947. */
  53948. export class DepthRenderer {
  53949. private _scene;
  53950. private _depthMap;
  53951. private _effect;
  53952. private _cachedDefines;
  53953. private _camera;
  53954. /**
  53955. * Specifiess that the depth renderer will only be used within
  53956. * the camera it is created for.
  53957. * This can help forcing its rendering during the camera processing.
  53958. */
  53959. useOnlyInActiveCamera: boolean;
  53960. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  53961. /**
  53962. * Instantiates a depth renderer
  53963. * @param scene The scene the renderer belongs to
  53964. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53965. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53966. */
  53967. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53968. /**
  53969. * Creates the depth rendering effect and checks if the effect is ready.
  53970. * @param subMesh The submesh to be used to render the depth map of
  53971. * @param useInstances If multiple world instances should be used
  53972. * @returns if the depth renderer is ready to render the depth map
  53973. */
  53974. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53975. /**
  53976. * Gets the texture which the depth map will be written to.
  53977. * @returns The depth map texture
  53978. */
  53979. getDepthMap(): RenderTargetTexture;
  53980. /**
  53981. * Disposes of the depth renderer.
  53982. */
  53983. dispose(): void;
  53984. }
  53985. }
  53986. declare module BABYLON {
  53987. interface Scene {
  53988. /** @hidden (Backing field) */ depthRenderer: {
  53989. [id: string]: DepthRenderer;
  53990. };
  53991. /**
  53992. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53993. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53994. * @returns the created depth renderer
  53995. */
  53996. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53997. /**
  53998. * Disables a depth renderer for a given camera
  53999. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54000. */
  54001. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54002. }
  54003. /**
  54004. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54005. * in several rendering techniques.
  54006. */
  54007. export class DepthRendererSceneComponent implements ISceneComponent {
  54008. /**
  54009. * The component name helpfull to identify the component in the list of scene components.
  54010. */
  54011. readonly name: string;
  54012. /**
  54013. * The scene the component belongs to.
  54014. */
  54015. scene: Scene;
  54016. /**
  54017. * Creates a new instance of the component for the given scene
  54018. * @param scene Defines the scene to register the component in
  54019. */
  54020. constructor(scene: Scene);
  54021. /**
  54022. * Registers the component in a given scene
  54023. */
  54024. register(): void;
  54025. /**
  54026. * Rebuilds the elements related to this component in case of
  54027. * context lost for instance.
  54028. */
  54029. rebuild(): void;
  54030. /**
  54031. * Disposes the component and the associated ressources
  54032. */
  54033. dispose(): void;
  54034. private _gatherRenderTargets;
  54035. private _gatherActiveCameraRenderTargets;
  54036. }
  54037. }
  54038. declare module BABYLON {
  54039. /** @hidden */
  54040. export var outlinePixelShader: {
  54041. name: string;
  54042. shader: string;
  54043. };
  54044. }
  54045. declare module BABYLON {
  54046. /** @hidden */
  54047. export var outlineVertexShader: {
  54048. name: string;
  54049. shader: string;
  54050. };
  54051. }
  54052. declare module BABYLON {
  54053. interface Scene {
  54054. /** @hidden */ outlineRenderer: OutlineRenderer;
  54055. /**
  54056. * Gets the outline renderer associated with the scene
  54057. * @returns a OutlineRenderer
  54058. */
  54059. getOutlineRenderer(): OutlineRenderer;
  54060. }
  54061. interface AbstractMesh {
  54062. /** @hidden (Backing field) */ renderOutline: boolean;
  54063. /**
  54064. * Gets or sets a boolean indicating if the outline must be rendered as well
  54065. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54066. */
  54067. renderOutline: boolean;
  54068. /** @hidden (Backing field) */ renderOverlay: boolean;
  54069. /**
  54070. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54071. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54072. */
  54073. renderOverlay: boolean;
  54074. }
  54075. /**
  54076. * This class is responsible to draw bothe outline/overlay of meshes.
  54077. * It should not be used directly but through the available method on mesh.
  54078. */
  54079. export class OutlineRenderer implements ISceneComponent {
  54080. /**
  54081. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54082. */
  54083. private static _StencilReference;
  54084. /**
  54085. * The name of the component. Each component must have a unique name.
  54086. */
  54087. name: string;
  54088. /**
  54089. * The scene the component belongs to.
  54090. */
  54091. scene: Scene;
  54092. /**
  54093. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54094. */
  54095. zOffset: number;
  54096. private _engine;
  54097. private _effect;
  54098. private _cachedDefines;
  54099. private _savedDepthWrite;
  54100. /**
  54101. * Instantiates a new outline renderer. (There could be only one per scene).
  54102. * @param scene Defines the scene it belongs to
  54103. */
  54104. constructor(scene: Scene);
  54105. /**
  54106. * Register the component to one instance of a scene.
  54107. */
  54108. register(): void;
  54109. /**
  54110. * Rebuilds the elements related to this component in case of
  54111. * context lost for instance.
  54112. */
  54113. rebuild(): void;
  54114. /**
  54115. * Disposes the component and the associated ressources.
  54116. */
  54117. dispose(): void;
  54118. /**
  54119. * Renders the outline in the canvas.
  54120. * @param subMesh Defines the sumesh to render
  54121. * @param batch Defines the batch of meshes in case of instances
  54122. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54123. */
  54124. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54125. /**
  54126. * Returns whether or not the outline renderer is ready for a given submesh.
  54127. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54128. * @param subMesh Defines the submesh to check readyness for
  54129. * @param useInstances Defines wheter wee are trying to render instances or not
  54130. * @returns true if ready otherwise false
  54131. */
  54132. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54133. private _beforeRenderingMesh;
  54134. private _afterRenderingMesh;
  54135. }
  54136. }
  54137. declare module BABYLON {
  54138. /**
  54139. * Defines the list of states available for a task inside a AssetsManager
  54140. */
  54141. export enum AssetTaskState {
  54142. /**
  54143. * Initialization
  54144. */
  54145. INIT = 0,
  54146. /**
  54147. * Running
  54148. */
  54149. RUNNING = 1,
  54150. /**
  54151. * Done
  54152. */
  54153. DONE = 2,
  54154. /**
  54155. * Error
  54156. */
  54157. ERROR = 3
  54158. }
  54159. /**
  54160. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54161. */
  54162. export abstract class AbstractAssetTask {
  54163. /**
  54164. * Task name
  54165. */ name: string;
  54166. /**
  54167. * Callback called when the task is successful
  54168. */
  54169. onSuccess: (task: any) => void;
  54170. /**
  54171. * Callback called when the task is not successful
  54172. */
  54173. onError: (task: any, message?: string, exception?: any) => void;
  54174. /**
  54175. * Creates a new AssetsManager
  54176. * @param name defines the name of the task
  54177. */
  54178. constructor(
  54179. /**
  54180. * Task name
  54181. */ name: string);
  54182. private _isCompleted;
  54183. private _taskState;
  54184. private _errorObject;
  54185. /**
  54186. * Get if the task is completed
  54187. */
  54188. readonly isCompleted: boolean;
  54189. /**
  54190. * Gets the current state of the task
  54191. */
  54192. readonly taskState: AssetTaskState;
  54193. /**
  54194. * Gets the current error object (if task is in error)
  54195. */
  54196. readonly errorObject: {
  54197. message?: string;
  54198. exception?: any;
  54199. };
  54200. /**
  54201. * Internal only
  54202. * @hidden
  54203. */ setErrorObject(message?: string, exception?: any): void;
  54204. /**
  54205. * Execute the current task
  54206. * @param scene defines the scene where you want your assets to be loaded
  54207. * @param onSuccess is a callback called when the task is successfully executed
  54208. * @param onError is a callback called if an error occurs
  54209. */
  54210. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54211. /**
  54212. * Execute the current task
  54213. * @param scene defines the scene where you want your assets to be loaded
  54214. * @param onSuccess is a callback called when the task is successfully executed
  54215. * @param onError is a callback called if an error occurs
  54216. */
  54217. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54218. /**
  54219. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54220. * This can be used with failed tasks that have the reason for failure fixed.
  54221. */
  54222. reset(): void;
  54223. private onErrorCallback;
  54224. private onDoneCallback;
  54225. }
  54226. /**
  54227. * Define the interface used by progress events raised during assets loading
  54228. */
  54229. export interface IAssetsProgressEvent {
  54230. /**
  54231. * Defines the number of remaining tasks to process
  54232. */
  54233. remainingCount: number;
  54234. /**
  54235. * Defines the total number of tasks
  54236. */
  54237. totalCount: number;
  54238. /**
  54239. * Defines the task that was just processed
  54240. */
  54241. task: AbstractAssetTask;
  54242. }
  54243. /**
  54244. * Class used to share progress information about assets loading
  54245. */
  54246. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54247. /**
  54248. * Defines the number of remaining tasks to process
  54249. */
  54250. remainingCount: number;
  54251. /**
  54252. * Defines the total number of tasks
  54253. */
  54254. totalCount: number;
  54255. /**
  54256. * Defines the task that was just processed
  54257. */
  54258. task: AbstractAssetTask;
  54259. /**
  54260. * Creates a AssetsProgressEvent
  54261. * @param remainingCount defines the number of remaining tasks to process
  54262. * @param totalCount defines the total number of tasks
  54263. * @param task defines the task that was just processed
  54264. */
  54265. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54266. }
  54267. /**
  54268. * Define a task used by AssetsManager to load meshes
  54269. */
  54270. export class MeshAssetTask extends AbstractAssetTask {
  54271. /**
  54272. * Defines the name of the task
  54273. */
  54274. name: string;
  54275. /**
  54276. * Defines the list of mesh's names you want to load
  54277. */
  54278. meshesNames: any;
  54279. /**
  54280. * Defines the root url to use as a base to load your meshes and associated resources
  54281. */
  54282. rootUrl: string;
  54283. /**
  54284. * Defines the filename of the scene to load from
  54285. */
  54286. sceneFilename: string;
  54287. /**
  54288. * Gets the list of loaded meshes
  54289. */
  54290. loadedMeshes: Array<AbstractMesh>;
  54291. /**
  54292. * Gets the list of loaded particle systems
  54293. */
  54294. loadedParticleSystems: Array<IParticleSystem>;
  54295. /**
  54296. * Gets the list of loaded skeletons
  54297. */
  54298. loadedSkeletons: Array<Skeleton>;
  54299. /**
  54300. * Gets the list of loaded animation groups
  54301. */
  54302. loadedAnimationGroups: Array<AnimationGroup>;
  54303. /**
  54304. * Callback called when the task is successful
  54305. */
  54306. onSuccess: (task: MeshAssetTask) => void;
  54307. /**
  54308. * Callback called when the task is successful
  54309. */
  54310. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54311. /**
  54312. * Creates a new MeshAssetTask
  54313. * @param name defines the name of the task
  54314. * @param meshesNames defines the list of mesh's names you want to load
  54315. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54316. * @param sceneFilename defines the filename of the scene to load from
  54317. */
  54318. constructor(
  54319. /**
  54320. * Defines the name of the task
  54321. */
  54322. name: string,
  54323. /**
  54324. * Defines the list of mesh's names you want to load
  54325. */
  54326. meshesNames: any,
  54327. /**
  54328. * Defines the root url to use as a base to load your meshes and associated resources
  54329. */
  54330. rootUrl: string,
  54331. /**
  54332. * Defines the filename of the scene to load from
  54333. */
  54334. sceneFilename: string);
  54335. /**
  54336. * Execute the current task
  54337. * @param scene defines the scene where you want your assets to be loaded
  54338. * @param onSuccess is a callback called when the task is successfully executed
  54339. * @param onError is a callback called if an error occurs
  54340. */
  54341. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54342. }
  54343. /**
  54344. * Define a task used by AssetsManager to load text content
  54345. */
  54346. export class TextFileAssetTask extends AbstractAssetTask {
  54347. /**
  54348. * Defines the name of the task
  54349. */
  54350. name: string;
  54351. /**
  54352. * Defines the location of the file to load
  54353. */
  54354. url: string;
  54355. /**
  54356. * Gets the loaded text string
  54357. */
  54358. text: string;
  54359. /**
  54360. * Callback called when the task is successful
  54361. */
  54362. onSuccess: (task: TextFileAssetTask) => void;
  54363. /**
  54364. * Callback called when the task is successful
  54365. */
  54366. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54367. /**
  54368. * Creates a new TextFileAssetTask object
  54369. * @param name defines the name of the task
  54370. * @param url defines the location of the file to load
  54371. */
  54372. constructor(
  54373. /**
  54374. * Defines the name of the task
  54375. */
  54376. name: string,
  54377. /**
  54378. * Defines the location of the file to load
  54379. */
  54380. url: string);
  54381. /**
  54382. * Execute the current task
  54383. * @param scene defines the scene where you want your assets to be loaded
  54384. * @param onSuccess is a callback called when the task is successfully executed
  54385. * @param onError is a callback called if an error occurs
  54386. */
  54387. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54388. }
  54389. /**
  54390. * Define a task used by AssetsManager to load binary data
  54391. */
  54392. export class BinaryFileAssetTask extends AbstractAssetTask {
  54393. /**
  54394. * Defines the name of the task
  54395. */
  54396. name: string;
  54397. /**
  54398. * Defines the location of the file to load
  54399. */
  54400. url: string;
  54401. /**
  54402. * Gets the lodaded data (as an array buffer)
  54403. */
  54404. data: ArrayBuffer;
  54405. /**
  54406. * Callback called when the task is successful
  54407. */
  54408. onSuccess: (task: BinaryFileAssetTask) => void;
  54409. /**
  54410. * Callback called when the task is successful
  54411. */
  54412. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54413. /**
  54414. * Creates a new BinaryFileAssetTask object
  54415. * @param name defines the name of the new task
  54416. * @param url defines the location of the file to load
  54417. */
  54418. constructor(
  54419. /**
  54420. * Defines the name of the task
  54421. */
  54422. name: string,
  54423. /**
  54424. * Defines the location of the file to load
  54425. */
  54426. url: string);
  54427. /**
  54428. * Execute the current task
  54429. * @param scene defines the scene where you want your assets to be loaded
  54430. * @param onSuccess is a callback called when the task is successfully executed
  54431. * @param onError is a callback called if an error occurs
  54432. */
  54433. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54434. }
  54435. /**
  54436. * Define a task used by AssetsManager to load images
  54437. */
  54438. export class ImageAssetTask extends AbstractAssetTask {
  54439. /**
  54440. * Defines the name of the task
  54441. */
  54442. name: string;
  54443. /**
  54444. * Defines the location of the image to load
  54445. */
  54446. url: string;
  54447. /**
  54448. * Gets the loaded images
  54449. */
  54450. image: HTMLImageElement;
  54451. /**
  54452. * Callback called when the task is successful
  54453. */
  54454. onSuccess: (task: ImageAssetTask) => void;
  54455. /**
  54456. * Callback called when the task is successful
  54457. */
  54458. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54459. /**
  54460. * Creates a new ImageAssetTask
  54461. * @param name defines the name of the task
  54462. * @param url defines the location of the image to load
  54463. */
  54464. constructor(
  54465. /**
  54466. * Defines the name of the task
  54467. */
  54468. name: string,
  54469. /**
  54470. * Defines the location of the image to load
  54471. */
  54472. url: string);
  54473. /**
  54474. * Execute the current task
  54475. * @param scene defines the scene where you want your assets to be loaded
  54476. * @param onSuccess is a callback called when the task is successfully executed
  54477. * @param onError is a callback called if an error occurs
  54478. */
  54479. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54480. }
  54481. /**
  54482. * Defines the interface used by texture loading tasks
  54483. */
  54484. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54485. /**
  54486. * Gets the loaded texture
  54487. */
  54488. texture: TEX;
  54489. }
  54490. /**
  54491. * Define a task used by AssetsManager to load 2D textures
  54492. */
  54493. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54494. /**
  54495. * Defines the name of the task
  54496. */
  54497. name: string;
  54498. /**
  54499. * Defines the location of the file to load
  54500. */
  54501. url: string;
  54502. /**
  54503. * Defines if mipmap should not be generated (default is false)
  54504. */
  54505. noMipmap?: boolean | undefined;
  54506. /**
  54507. * Defines if texture must be inverted on Y axis (default is false)
  54508. */
  54509. invertY?: boolean | undefined;
  54510. /**
  54511. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54512. */
  54513. samplingMode: number;
  54514. /**
  54515. * Gets the loaded texture
  54516. */
  54517. texture: Texture;
  54518. /**
  54519. * Callback called when the task is successful
  54520. */
  54521. onSuccess: (task: TextureAssetTask) => void;
  54522. /**
  54523. * Callback called when the task is successful
  54524. */
  54525. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54526. /**
  54527. * Creates a new TextureAssetTask object
  54528. * @param name defines the name of the task
  54529. * @param url defines the location of the file to load
  54530. * @param noMipmap defines if mipmap should not be generated (default is false)
  54531. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54532. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54533. */
  54534. constructor(
  54535. /**
  54536. * Defines the name of the task
  54537. */
  54538. name: string,
  54539. /**
  54540. * Defines the location of the file to load
  54541. */
  54542. url: string,
  54543. /**
  54544. * Defines if mipmap should not be generated (default is false)
  54545. */
  54546. noMipmap?: boolean | undefined,
  54547. /**
  54548. * Defines if texture must be inverted on Y axis (default is false)
  54549. */
  54550. invertY?: boolean | undefined,
  54551. /**
  54552. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54553. */
  54554. samplingMode?: number);
  54555. /**
  54556. * Execute the current task
  54557. * @param scene defines the scene where you want your assets to be loaded
  54558. * @param onSuccess is a callback called when the task is successfully executed
  54559. * @param onError is a callback called if an error occurs
  54560. */
  54561. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54562. }
  54563. /**
  54564. * Define a task used by AssetsManager to load cube textures
  54565. */
  54566. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54567. /**
  54568. * Defines the name of the task
  54569. */
  54570. name: string;
  54571. /**
  54572. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54573. */
  54574. url: string;
  54575. /**
  54576. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54577. */
  54578. extensions?: string[] | undefined;
  54579. /**
  54580. * Defines if mipmaps should not be generated (default is false)
  54581. */
  54582. noMipmap?: boolean | undefined;
  54583. /**
  54584. * Defines the explicit list of files (undefined by default)
  54585. */
  54586. files?: string[] | undefined;
  54587. /**
  54588. * Gets the loaded texture
  54589. */
  54590. texture: CubeTexture;
  54591. /**
  54592. * Callback called when the task is successful
  54593. */
  54594. onSuccess: (task: CubeTextureAssetTask) => void;
  54595. /**
  54596. * Callback called when the task is successful
  54597. */
  54598. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54599. /**
  54600. * Creates a new CubeTextureAssetTask
  54601. * @param name defines the name of the task
  54602. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54603. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54604. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54605. * @param files defines the explicit list of files (undefined by default)
  54606. */
  54607. constructor(
  54608. /**
  54609. * Defines the name of the task
  54610. */
  54611. name: string,
  54612. /**
  54613. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54614. */
  54615. url: string,
  54616. /**
  54617. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54618. */
  54619. extensions?: string[] | undefined,
  54620. /**
  54621. * Defines if mipmaps should not be generated (default is false)
  54622. */
  54623. noMipmap?: boolean | undefined,
  54624. /**
  54625. * Defines the explicit list of files (undefined by default)
  54626. */
  54627. files?: string[] | undefined);
  54628. /**
  54629. * Execute the current task
  54630. * @param scene defines the scene where you want your assets to be loaded
  54631. * @param onSuccess is a callback called when the task is successfully executed
  54632. * @param onError is a callback called if an error occurs
  54633. */
  54634. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54635. }
  54636. /**
  54637. * Define a task used by AssetsManager to load HDR cube textures
  54638. */
  54639. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54640. /**
  54641. * Defines the name of the task
  54642. */
  54643. name: string;
  54644. /**
  54645. * Defines the location of the file to load
  54646. */
  54647. url: string;
  54648. /**
  54649. * Defines the desired size (the more it increases the longer the generation will be)
  54650. */
  54651. size: number;
  54652. /**
  54653. * Defines if mipmaps should not be generated (default is false)
  54654. */
  54655. noMipmap: boolean;
  54656. /**
  54657. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54658. */
  54659. generateHarmonics: boolean;
  54660. /**
  54661. * 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)
  54662. */
  54663. gammaSpace: boolean;
  54664. /**
  54665. * Internal Use Only
  54666. */
  54667. reserved: boolean;
  54668. /**
  54669. * Gets the loaded texture
  54670. */
  54671. texture: HDRCubeTexture;
  54672. /**
  54673. * Callback called when the task is successful
  54674. */
  54675. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54676. /**
  54677. * Callback called when the task is successful
  54678. */
  54679. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54680. /**
  54681. * Creates a new HDRCubeTextureAssetTask object
  54682. * @param name defines the name of the task
  54683. * @param url defines the location of the file to load
  54684. * @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.
  54685. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54686. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54687. * @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)
  54688. * @param reserved Internal use only
  54689. */
  54690. constructor(
  54691. /**
  54692. * Defines the name of the task
  54693. */
  54694. name: string,
  54695. /**
  54696. * Defines the location of the file to load
  54697. */
  54698. url: string,
  54699. /**
  54700. * Defines the desired size (the more it increases the longer the generation will be)
  54701. */
  54702. size: number,
  54703. /**
  54704. * Defines if mipmaps should not be generated (default is false)
  54705. */
  54706. noMipmap?: boolean,
  54707. /**
  54708. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54709. */
  54710. generateHarmonics?: boolean,
  54711. /**
  54712. * 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)
  54713. */
  54714. gammaSpace?: boolean,
  54715. /**
  54716. * Internal Use Only
  54717. */
  54718. reserved?: boolean);
  54719. /**
  54720. * Execute the current task
  54721. * @param scene defines the scene where you want your assets to be loaded
  54722. * @param onSuccess is a callback called when the task is successfully executed
  54723. * @param onError is a callback called if an error occurs
  54724. */
  54725. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54726. }
  54727. /**
  54728. * Define a task used by AssetsManager to load Equirectangular cube textures
  54729. */
  54730. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  54731. /**
  54732. * Defines the name of the task
  54733. */
  54734. name: string;
  54735. /**
  54736. * Defines the location of the file to load
  54737. */
  54738. url: string;
  54739. /**
  54740. * Defines the desired size (the more it increases the longer the generation will be)
  54741. */
  54742. size: number;
  54743. /**
  54744. * Defines if mipmaps should not be generated (default is false)
  54745. */
  54746. noMipmap: boolean;
  54747. /**
  54748. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54749. * but the standard material would require them in Gamma space) (default is true)
  54750. */
  54751. gammaSpace: boolean;
  54752. /**
  54753. * Gets the loaded texture
  54754. */
  54755. texture: EquiRectangularCubeTexture;
  54756. /**
  54757. * Callback called when the task is successful
  54758. */
  54759. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  54760. /**
  54761. * Callback called when the task is successful
  54762. */
  54763. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  54764. /**
  54765. * Creates a new EquiRectangularCubeTextureAssetTask object
  54766. * @param name defines the name of the task
  54767. * @param url defines the location of the file to load
  54768. * @param size defines the desired size (the more it increases the longer the generation will be)
  54769. * If the size is omitted this implies you are using a preprocessed cubemap.
  54770. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54771. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  54772. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54773. * (default is true)
  54774. */
  54775. constructor(
  54776. /**
  54777. * Defines the name of the task
  54778. */
  54779. name: string,
  54780. /**
  54781. * Defines the location of the file to load
  54782. */
  54783. url: string,
  54784. /**
  54785. * Defines the desired size (the more it increases the longer the generation will be)
  54786. */
  54787. size: number,
  54788. /**
  54789. * Defines if mipmaps should not be generated (default is false)
  54790. */
  54791. noMipmap?: boolean,
  54792. /**
  54793. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54794. * but the standard material would require them in Gamma space) (default is true)
  54795. */
  54796. gammaSpace?: boolean);
  54797. /**
  54798. * Execute the current task
  54799. * @param scene defines the scene where you want your assets to be loaded
  54800. * @param onSuccess is a callback called when the task is successfully executed
  54801. * @param onError is a callback called if an error occurs
  54802. */
  54803. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54804. }
  54805. /**
  54806. * This class can be used to easily import assets into a scene
  54807. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54808. */
  54809. export class AssetsManager {
  54810. private _scene;
  54811. private _isLoading;
  54812. protected _tasks: AbstractAssetTask[];
  54813. protected _waitingTasksCount: number;
  54814. protected _totalTasksCount: number;
  54815. /**
  54816. * Callback called when all tasks are processed
  54817. */
  54818. onFinish: (tasks: AbstractAssetTask[]) => void;
  54819. /**
  54820. * Callback called when a task is successful
  54821. */
  54822. onTaskSuccess: (task: AbstractAssetTask) => void;
  54823. /**
  54824. * Callback called when a task had an error
  54825. */
  54826. onTaskError: (task: AbstractAssetTask) => void;
  54827. /**
  54828. * Callback called when a task is done (whatever the result is)
  54829. */
  54830. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54831. /**
  54832. * Observable called when all tasks are processed
  54833. */
  54834. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54835. /**
  54836. * Observable called when a task had an error
  54837. */
  54838. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54839. /**
  54840. * Observable called when all tasks were executed
  54841. */
  54842. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54843. /**
  54844. * Observable called when a task is done (whatever the result is)
  54845. */
  54846. onProgressObservable: Observable<IAssetsProgressEvent>;
  54847. /**
  54848. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54849. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54850. */
  54851. useDefaultLoadingScreen: boolean;
  54852. /**
  54853. * Creates a new AssetsManager
  54854. * @param scene defines the scene to work on
  54855. */
  54856. constructor(scene: Scene);
  54857. /**
  54858. * Add a MeshAssetTask to the list of active tasks
  54859. * @param taskName defines the name of the new task
  54860. * @param meshesNames defines the name of meshes to load
  54861. * @param rootUrl defines the root url to use to locate files
  54862. * @param sceneFilename defines the filename of the scene file
  54863. * @returns a new MeshAssetTask object
  54864. */
  54865. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54866. /**
  54867. * Add a TextFileAssetTask to the list of active tasks
  54868. * @param taskName defines the name of the new task
  54869. * @param url defines the url of the file to load
  54870. * @returns a new TextFileAssetTask object
  54871. */
  54872. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54873. /**
  54874. * Add a BinaryFileAssetTask to the list of active tasks
  54875. * @param taskName defines the name of the new task
  54876. * @param url defines the url of the file to load
  54877. * @returns a new BinaryFileAssetTask object
  54878. */
  54879. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54880. /**
  54881. * Add a ImageAssetTask to the list of active tasks
  54882. * @param taskName defines the name of the new task
  54883. * @param url defines the url of the file to load
  54884. * @returns a new ImageAssetTask object
  54885. */
  54886. addImageTask(taskName: string, url: string): ImageAssetTask;
  54887. /**
  54888. * Add a TextureAssetTask to the list of active tasks
  54889. * @param taskName defines the name of the new task
  54890. * @param url defines the url of the file to load
  54891. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54892. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54893. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54894. * @returns a new TextureAssetTask object
  54895. */
  54896. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54897. /**
  54898. * Add a CubeTextureAssetTask to the list of active tasks
  54899. * @param taskName defines the name of the new task
  54900. * @param url defines the url of the file to load
  54901. * @param extensions defines the extension to use to load the cube map (can be null)
  54902. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54903. * @param files defines the list of files to load (can be null)
  54904. * @returns a new CubeTextureAssetTask object
  54905. */
  54906. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54907. /**
  54908. *
  54909. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54910. * @param taskName defines the name of the new task
  54911. * @param url defines the url of the file to load
  54912. * @param size defines the size you want for the cubemap (can be null)
  54913. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54914. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54915. * @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)
  54916. * @param reserved Internal use only
  54917. * @returns a new HDRCubeTextureAssetTask object
  54918. */
  54919. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54920. /**
  54921. *
  54922. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  54923. * @param taskName defines the name of the new task
  54924. * @param url defines the url of the file to load
  54925. * @param size defines the size you want for the cubemap (can be null)
  54926. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54927. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54928. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54929. * @returns a new EquiRectangularCubeTextureAssetTask object
  54930. */
  54931. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  54932. /**
  54933. * Remove a task from the assets manager.
  54934. * @param task the task to remove
  54935. */
  54936. removeTask(task: AbstractAssetTask): void;
  54937. private _decreaseWaitingTasksCount;
  54938. private _runTask;
  54939. /**
  54940. * Reset the AssetsManager and remove all tasks
  54941. * @return the current instance of the AssetsManager
  54942. */
  54943. reset(): AssetsManager;
  54944. /**
  54945. * Start the loading process
  54946. * @return the current instance of the AssetsManager
  54947. */
  54948. load(): AssetsManager;
  54949. /**
  54950. * Start the loading process as an async operation
  54951. * @return a promise returning the list of failed tasks
  54952. */
  54953. loadAsync(): Promise<void>;
  54954. }
  54955. }
  54956. declare module BABYLON {
  54957. /**
  54958. * Wrapper class for promise with external resolve and reject.
  54959. */
  54960. export class Deferred<T> {
  54961. /**
  54962. * The promise associated with this deferred object.
  54963. */
  54964. readonly promise: Promise<T>;
  54965. private _resolve;
  54966. private _reject;
  54967. /**
  54968. * The resolve method of the promise associated with this deferred object.
  54969. */
  54970. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54971. /**
  54972. * The reject method of the promise associated with this deferred object.
  54973. */
  54974. readonly reject: (reason?: any) => void;
  54975. /**
  54976. * Constructor for this deferred object.
  54977. */
  54978. constructor();
  54979. }
  54980. }
  54981. declare module BABYLON {
  54982. /**
  54983. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  54984. */
  54985. export class MeshExploder {
  54986. private _centerMesh;
  54987. private _meshes;
  54988. private _meshesOrigins;
  54989. private _toCenterVectors;
  54990. private _scaledDirection;
  54991. private _newPosition;
  54992. private _centerPosition;
  54993. /**
  54994. * Explodes meshes from a center mesh.
  54995. * @param meshes The meshes to explode.
  54996. * @param centerMesh The mesh to be center of explosion.
  54997. */
  54998. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  54999. private _setCenterMesh;
  55000. /**
  55001. * Get class name
  55002. * @returns "MeshExploder"
  55003. */
  55004. getClassName(): string;
  55005. /**
  55006. * "Exploded meshes"
  55007. * @returns Array of meshes with the centerMesh at index 0.
  55008. */
  55009. getMeshes(): Array<Mesh>;
  55010. /**
  55011. * Explodes meshes giving a specific direction
  55012. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55013. */
  55014. explode(direction?: number): void;
  55015. }
  55016. }
  55017. declare module BABYLON {
  55018. /**
  55019. * Class used to help managing file picking and drag'n'drop
  55020. */
  55021. export class FilesInput {
  55022. /**
  55023. * List of files ready to be loaded
  55024. */
  55025. static readonly FilesToLoad: {
  55026. [key: string]: File;
  55027. };
  55028. /**
  55029. * Callback called when a file is processed
  55030. */
  55031. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55032. private _engine;
  55033. private _currentScene;
  55034. private _sceneLoadedCallback;
  55035. private _progressCallback;
  55036. private _additionalRenderLoopLogicCallback;
  55037. private _textureLoadingCallback;
  55038. private _startingProcessingFilesCallback;
  55039. private _onReloadCallback;
  55040. private _errorCallback;
  55041. private _elementToMonitor;
  55042. private _sceneFileToLoad;
  55043. private _filesToLoad;
  55044. /**
  55045. * Creates a new FilesInput
  55046. * @param engine defines the rendering engine
  55047. * @param scene defines the hosting scene
  55048. * @param sceneLoadedCallback callback called when scene is loaded
  55049. * @param progressCallback callback called to track progress
  55050. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55051. * @param textureLoadingCallback callback called when a texture is loading
  55052. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55053. * @param onReloadCallback callback called when a reload is requested
  55054. * @param errorCallback callback call if an error occurs
  55055. */
  55056. 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);
  55057. private _dragEnterHandler;
  55058. private _dragOverHandler;
  55059. private _dropHandler;
  55060. /**
  55061. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55062. * @param elementToMonitor defines the DOM element to track
  55063. */
  55064. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55065. /**
  55066. * Release all associated resources
  55067. */
  55068. dispose(): void;
  55069. private renderFunction;
  55070. private drag;
  55071. private drop;
  55072. private _traverseFolder;
  55073. private _processFiles;
  55074. /**
  55075. * Load files from a drop event
  55076. * @param event defines the drop event to use as source
  55077. */
  55078. loadFiles(event: any): void;
  55079. private _processReload;
  55080. /**
  55081. * Reload the current scene from the loaded files
  55082. */
  55083. reload(): void;
  55084. }
  55085. }
  55086. declare module BABYLON {
  55087. /**
  55088. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55089. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55090. */
  55091. export class SceneOptimization {
  55092. /**
  55093. * Defines the priority of this optimization (0 by default which means first in the list)
  55094. */
  55095. priority: number;
  55096. /**
  55097. * Gets a string describing the action executed by the current optimization
  55098. * @returns description string
  55099. */
  55100. getDescription(): string;
  55101. /**
  55102. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55103. * @param scene defines the current scene where to apply this optimization
  55104. * @param optimizer defines the current optimizer
  55105. * @returns true if everything that can be done was applied
  55106. */
  55107. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55108. /**
  55109. * Creates the SceneOptimization object
  55110. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55111. * @param desc defines the description associated with the optimization
  55112. */
  55113. constructor(
  55114. /**
  55115. * Defines the priority of this optimization (0 by default which means first in the list)
  55116. */
  55117. priority?: number);
  55118. }
  55119. /**
  55120. * Defines an optimization used to reduce the size of render target textures
  55121. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55122. */
  55123. export class TextureOptimization extends SceneOptimization {
  55124. /**
  55125. * Defines the priority of this optimization (0 by default which means first in the list)
  55126. */
  55127. priority: number;
  55128. /**
  55129. * 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
  55130. */
  55131. maximumSize: number;
  55132. /**
  55133. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55134. */
  55135. step: number;
  55136. /**
  55137. * Gets a string describing the action executed by the current optimization
  55138. * @returns description string
  55139. */
  55140. getDescription(): string;
  55141. /**
  55142. * Creates the TextureOptimization object
  55143. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55144. * @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
  55145. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55146. */
  55147. constructor(
  55148. /**
  55149. * Defines the priority of this optimization (0 by default which means first in the list)
  55150. */
  55151. priority?: number,
  55152. /**
  55153. * 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
  55154. */
  55155. maximumSize?: number,
  55156. /**
  55157. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55158. */
  55159. step?: number);
  55160. /**
  55161. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55162. * @param scene defines the current scene where to apply this optimization
  55163. * @param optimizer defines the current optimizer
  55164. * @returns true if everything that can be done was applied
  55165. */
  55166. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55167. }
  55168. /**
  55169. * Defines an optimization used to increase or decrease the rendering resolution
  55170. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55171. */
  55172. export class HardwareScalingOptimization extends SceneOptimization {
  55173. /**
  55174. * Defines the priority of this optimization (0 by default which means first in the list)
  55175. */
  55176. priority: number;
  55177. /**
  55178. * Defines the maximum scale to use (2 by default)
  55179. */
  55180. maximumScale: number;
  55181. /**
  55182. * Defines the step to use between two passes (0.5 by default)
  55183. */
  55184. step: number;
  55185. private _currentScale;
  55186. private _directionOffset;
  55187. /**
  55188. * Gets a string describing the action executed by the current optimization
  55189. * @return description string
  55190. */
  55191. getDescription(): string;
  55192. /**
  55193. * Creates the HardwareScalingOptimization object
  55194. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55195. * @param maximumScale defines the maximum scale to use (2 by default)
  55196. * @param step defines the step to use between two passes (0.5 by default)
  55197. */
  55198. constructor(
  55199. /**
  55200. * Defines the priority of this optimization (0 by default which means first in the list)
  55201. */
  55202. priority?: number,
  55203. /**
  55204. * Defines the maximum scale to use (2 by default)
  55205. */
  55206. maximumScale?: number,
  55207. /**
  55208. * Defines the step to use between two passes (0.5 by default)
  55209. */
  55210. step?: number);
  55211. /**
  55212. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55213. * @param scene defines the current scene where to apply this optimization
  55214. * @param optimizer defines the current optimizer
  55215. * @returns true if everything that can be done was applied
  55216. */
  55217. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55218. }
  55219. /**
  55220. * Defines an optimization used to remove shadows
  55221. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55222. */
  55223. export class ShadowsOptimization extends SceneOptimization {
  55224. /**
  55225. * Gets a string describing the action executed by the current optimization
  55226. * @return description string
  55227. */
  55228. getDescription(): string;
  55229. /**
  55230. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55231. * @param scene defines the current scene where to apply this optimization
  55232. * @param optimizer defines the current optimizer
  55233. * @returns true if everything that can be done was applied
  55234. */
  55235. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55236. }
  55237. /**
  55238. * Defines an optimization used to turn post-processes off
  55239. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55240. */
  55241. export class PostProcessesOptimization extends SceneOptimization {
  55242. /**
  55243. * Gets a string describing the action executed by the current optimization
  55244. * @return description string
  55245. */
  55246. getDescription(): string;
  55247. /**
  55248. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55249. * @param scene defines the current scene where to apply this optimization
  55250. * @param optimizer defines the current optimizer
  55251. * @returns true if everything that can be done was applied
  55252. */
  55253. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55254. }
  55255. /**
  55256. * Defines an optimization used to turn lens flares off
  55257. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55258. */
  55259. export class LensFlaresOptimization extends SceneOptimization {
  55260. /**
  55261. * Gets a string describing the action executed by the current optimization
  55262. * @return description string
  55263. */
  55264. getDescription(): string;
  55265. /**
  55266. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55267. * @param scene defines the current scene where to apply this optimization
  55268. * @param optimizer defines the current optimizer
  55269. * @returns true if everything that can be done was applied
  55270. */
  55271. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55272. }
  55273. /**
  55274. * Defines an optimization based on user defined callback.
  55275. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55276. */
  55277. export class CustomOptimization extends SceneOptimization {
  55278. /**
  55279. * Callback called to apply the custom optimization.
  55280. */
  55281. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55282. /**
  55283. * Callback called to get custom description
  55284. */
  55285. onGetDescription: () => string;
  55286. /**
  55287. * Gets a string describing the action executed by the current optimization
  55288. * @returns description string
  55289. */
  55290. getDescription(): string;
  55291. /**
  55292. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55293. * @param scene defines the current scene where to apply this optimization
  55294. * @param optimizer defines the current optimizer
  55295. * @returns true if everything that can be done was applied
  55296. */
  55297. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55298. }
  55299. /**
  55300. * Defines an optimization used to turn particles off
  55301. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55302. */
  55303. export class ParticlesOptimization extends SceneOptimization {
  55304. /**
  55305. * Gets a string describing the action executed by the current optimization
  55306. * @return description string
  55307. */
  55308. getDescription(): string;
  55309. /**
  55310. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55311. * @param scene defines the current scene where to apply this optimization
  55312. * @param optimizer defines the current optimizer
  55313. * @returns true if everything that can be done was applied
  55314. */
  55315. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55316. }
  55317. /**
  55318. * Defines an optimization used to turn render targets off
  55319. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55320. */
  55321. export class RenderTargetsOptimization extends SceneOptimization {
  55322. /**
  55323. * Gets a string describing the action executed by the current optimization
  55324. * @return description string
  55325. */
  55326. getDescription(): string;
  55327. /**
  55328. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55329. * @param scene defines the current scene where to apply this optimization
  55330. * @param optimizer defines the current optimizer
  55331. * @returns true if everything that can be done was applied
  55332. */
  55333. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55334. }
  55335. /**
  55336. * Defines an optimization used to merge meshes with compatible materials
  55337. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55338. */
  55339. export class MergeMeshesOptimization extends SceneOptimization {
  55340. private static _UpdateSelectionTree;
  55341. /**
  55342. * Gets or sets a boolean which defines if optimization octree has to be updated
  55343. */
  55344. /**
  55345. * Gets or sets a boolean which defines if optimization octree has to be updated
  55346. */
  55347. static UpdateSelectionTree: boolean;
  55348. /**
  55349. * Gets a string describing the action executed by the current optimization
  55350. * @return description string
  55351. */
  55352. getDescription(): string;
  55353. private _canBeMerged;
  55354. /**
  55355. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55356. * @param scene defines the current scene where to apply this optimization
  55357. * @param optimizer defines the current optimizer
  55358. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55359. * @returns true if everything that can be done was applied
  55360. */
  55361. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55362. }
  55363. /**
  55364. * Defines a list of options used by SceneOptimizer
  55365. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55366. */
  55367. export class SceneOptimizerOptions {
  55368. /**
  55369. * Defines the target frame rate to reach (60 by default)
  55370. */
  55371. targetFrameRate: number;
  55372. /**
  55373. * Defines the interval between two checkes (2000ms by default)
  55374. */
  55375. trackerDuration: number;
  55376. /**
  55377. * Gets the list of optimizations to apply
  55378. */
  55379. optimizations: SceneOptimization[];
  55380. /**
  55381. * Creates a new list of options used by SceneOptimizer
  55382. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55383. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55384. */
  55385. constructor(
  55386. /**
  55387. * Defines the target frame rate to reach (60 by default)
  55388. */
  55389. targetFrameRate?: number,
  55390. /**
  55391. * Defines the interval between two checkes (2000ms by default)
  55392. */
  55393. trackerDuration?: number);
  55394. /**
  55395. * Add a new optimization
  55396. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55397. * @returns the current SceneOptimizerOptions
  55398. */
  55399. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55400. /**
  55401. * Add a new custom optimization
  55402. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55403. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55404. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55405. * @returns the current SceneOptimizerOptions
  55406. */
  55407. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55408. /**
  55409. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55410. * @param targetFrameRate defines the target frame rate (60 by default)
  55411. * @returns a SceneOptimizerOptions object
  55412. */
  55413. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55414. /**
  55415. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55416. * @param targetFrameRate defines the target frame rate (60 by default)
  55417. * @returns a SceneOptimizerOptions object
  55418. */
  55419. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55420. /**
  55421. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55422. * @param targetFrameRate defines the target frame rate (60 by default)
  55423. * @returns a SceneOptimizerOptions object
  55424. */
  55425. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55426. }
  55427. /**
  55428. * Class used to run optimizations in order to reach a target frame rate
  55429. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55430. */
  55431. export class SceneOptimizer implements IDisposable {
  55432. private _isRunning;
  55433. private _options;
  55434. private _scene;
  55435. private _currentPriorityLevel;
  55436. private _targetFrameRate;
  55437. private _trackerDuration;
  55438. private _currentFrameRate;
  55439. private _sceneDisposeObserver;
  55440. private _improvementMode;
  55441. /**
  55442. * Defines an observable called when the optimizer reaches the target frame rate
  55443. */
  55444. onSuccessObservable: Observable<SceneOptimizer>;
  55445. /**
  55446. * Defines an observable called when the optimizer enables an optimization
  55447. */
  55448. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55449. /**
  55450. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55451. */
  55452. onFailureObservable: Observable<SceneOptimizer>;
  55453. /**
  55454. * Gets a boolean indicating if the optimizer is in improvement mode
  55455. */
  55456. readonly isInImprovementMode: boolean;
  55457. /**
  55458. * Gets the current priority level (0 at start)
  55459. */
  55460. readonly currentPriorityLevel: number;
  55461. /**
  55462. * Gets the current frame rate checked by the SceneOptimizer
  55463. */
  55464. readonly currentFrameRate: number;
  55465. /**
  55466. * Gets or sets the current target frame rate (60 by default)
  55467. */
  55468. /**
  55469. * Gets or sets the current target frame rate (60 by default)
  55470. */
  55471. targetFrameRate: number;
  55472. /**
  55473. * Gets or sets the current interval between two checks (every 2000ms by default)
  55474. */
  55475. /**
  55476. * Gets or sets the current interval between two checks (every 2000ms by default)
  55477. */
  55478. trackerDuration: number;
  55479. /**
  55480. * Gets the list of active optimizations
  55481. */
  55482. readonly optimizations: SceneOptimization[];
  55483. /**
  55484. * Creates a new SceneOptimizer
  55485. * @param scene defines the scene to work on
  55486. * @param options defines the options to use with the SceneOptimizer
  55487. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55488. * @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)
  55489. */
  55490. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55491. /**
  55492. * Stops the current optimizer
  55493. */
  55494. stop(): void;
  55495. /**
  55496. * Reset the optimizer to initial step (current priority level = 0)
  55497. */
  55498. reset(): void;
  55499. /**
  55500. * Start the optimizer. By default it will try to reach a specific framerate
  55501. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55502. */
  55503. start(): void;
  55504. private _checkCurrentState;
  55505. /**
  55506. * Release all resources
  55507. */
  55508. dispose(): void;
  55509. /**
  55510. * Helper function to create a SceneOptimizer with one single line of code
  55511. * @param scene defines the scene to work on
  55512. * @param options defines the options to use with the SceneOptimizer
  55513. * @param onSuccess defines a callback to call on success
  55514. * @param onFailure defines a callback to call on failure
  55515. * @returns the new SceneOptimizer object
  55516. */
  55517. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55518. }
  55519. }
  55520. declare module BABYLON {
  55521. /**
  55522. * Class used to serialize a scene into a string
  55523. */
  55524. export class SceneSerializer {
  55525. /**
  55526. * Clear cache used by a previous serialization
  55527. */
  55528. static ClearCache(): void;
  55529. /**
  55530. * Serialize a scene into a JSON compatible object
  55531. * @param scene defines the scene to serialize
  55532. * @returns a JSON compatible object
  55533. */
  55534. static Serialize(scene: Scene): any;
  55535. /**
  55536. * Serialize a mesh into a JSON compatible object
  55537. * @param toSerialize defines the mesh to serialize
  55538. * @param withParents defines if parents must be serialized as well
  55539. * @param withChildren defines if children must be serialized as well
  55540. * @returns a JSON compatible object
  55541. */
  55542. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55543. }
  55544. }
  55545. declare module BABYLON {
  55546. /**
  55547. * Class used to host texture specific utilities
  55548. */
  55549. export class TextureTools {
  55550. /**
  55551. * Uses the GPU to create a copy texture rescaled at a given size
  55552. * @param texture Texture to copy from
  55553. * @param width defines the desired width
  55554. * @param height defines the desired height
  55555. * @param useBilinearMode defines if bilinear mode has to be used
  55556. * @return the generated texture
  55557. */
  55558. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55559. }
  55560. }
  55561. declare module BABYLON {
  55562. /**
  55563. * This represents the different options avilable for the video capture.
  55564. */
  55565. export interface VideoRecorderOptions {
  55566. /** Defines the mime type of the video */
  55567. mimeType: string;
  55568. /** Defines the video the video should be recorded at */
  55569. fps: number;
  55570. /** Defines the chunk size for the recording data */
  55571. recordChunckSize: number;
  55572. /** The audio tracks to attach to the record */
  55573. audioTracks?: MediaStreamTrack[];
  55574. }
  55575. /**
  55576. * This can helps recording videos from BabylonJS.
  55577. * This is based on the available WebRTC functionalities of the browser.
  55578. *
  55579. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55580. */
  55581. export class VideoRecorder {
  55582. private static readonly _defaultOptions;
  55583. /**
  55584. * Returns wehther or not the VideoRecorder is available in your browser.
  55585. * @param engine Defines the Babylon Engine to check the support for
  55586. * @returns true if supported otherwise false
  55587. */
  55588. static IsSupported(engine: Engine): boolean;
  55589. private readonly _options;
  55590. private _canvas;
  55591. private _mediaRecorder;
  55592. private _recordedChunks;
  55593. private _fileName;
  55594. private _resolve;
  55595. private _reject;
  55596. /**
  55597. * True wether a recording is already in progress.
  55598. */
  55599. readonly isRecording: boolean;
  55600. /**
  55601. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55602. * a video file.
  55603. * @param engine Defines the BabylonJS Engine you wish to record
  55604. * @param options Defines options that can be used to customized the capture
  55605. */
  55606. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55607. /**
  55608. * Stops the current recording before the default capture timeout passed in the startRecording
  55609. * functions.
  55610. */
  55611. stopRecording(): void;
  55612. /**
  55613. * Starts recording the canvas for a max duration specified in parameters.
  55614. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  55615. * @param maxDuration Defines the maximum recording time in seconds.
  55616. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55617. * @return a promise callback at the end of the recording with the video data in Blob.
  55618. */
  55619. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55620. /**
  55621. * Releases internal resources used during the recording.
  55622. */
  55623. dispose(): void;
  55624. private _handleDataAvailable;
  55625. private _handleError;
  55626. private _handleStop;
  55627. }
  55628. }
  55629. declare module BABYLON {
  55630. /**
  55631. * Class containing a set of static utilities functions for screenshots
  55632. */
  55633. export class ScreenshotTools {
  55634. /**
  55635. * Captures a screenshot of the current rendering
  55636. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55637. * @param engine defines the rendering engine
  55638. * @param camera defines the source camera
  55639. * @param size This parameter can be set to a single number or to an object with the
  55640. * following (optional) properties: precision, width, height. If a single number is passed,
  55641. * it will be used for both width and height. If an object is passed, the screenshot size
  55642. * will be derived from the parameters. The precision property is a multiplier allowing
  55643. * rendering at a higher or lower resolution
  55644. * @param successCallback defines the callback receives a single parameter which contains the
  55645. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55646. * src parameter of an <img> to display it
  55647. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55648. * Check your browser for supported MIME types
  55649. */
  55650. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55651. /**
  55652. * Generates an image screenshot from the specified camera.
  55653. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55654. * @param engine The engine to use for rendering
  55655. * @param camera The camera to use for rendering
  55656. * @param size This parameter can be set to a single number or to an object with the
  55657. * following (optional) properties: precision, width, height. If a single number is passed,
  55658. * it will be used for both width and height. If an object is passed, the screenshot size
  55659. * will be derived from the parameters. The precision property is a multiplier allowing
  55660. * rendering at a higher or lower resolution
  55661. * @param successCallback The callback receives a single parameter which contains the
  55662. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55663. * src parameter of an <img> to display it
  55664. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55665. * Check your browser for supported MIME types
  55666. * @param samples Texture samples (default: 1)
  55667. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55668. * @param fileName A name for for the downloaded file.
  55669. */
  55670. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55671. }
  55672. }
  55673. declare module BABYLON {
  55674. /**
  55675. * A cursor which tracks a point on a path
  55676. */
  55677. export class PathCursor {
  55678. private path;
  55679. /**
  55680. * Stores path cursor callbacks for when an onchange event is triggered
  55681. */
  55682. private _onchange;
  55683. /**
  55684. * The value of the path cursor
  55685. */
  55686. value: number;
  55687. /**
  55688. * The animation array of the path cursor
  55689. */
  55690. animations: Animation[];
  55691. /**
  55692. * Initializes the path cursor
  55693. * @param path The path to track
  55694. */
  55695. constructor(path: Path2);
  55696. /**
  55697. * Gets the cursor point on the path
  55698. * @returns A point on the path cursor at the cursor location
  55699. */
  55700. getPoint(): Vector3;
  55701. /**
  55702. * Moves the cursor ahead by the step amount
  55703. * @param step The amount to move the cursor forward
  55704. * @returns This path cursor
  55705. */
  55706. moveAhead(step?: number): PathCursor;
  55707. /**
  55708. * Moves the cursor behind by the step amount
  55709. * @param step The amount to move the cursor back
  55710. * @returns This path cursor
  55711. */
  55712. moveBack(step?: number): PathCursor;
  55713. /**
  55714. * Moves the cursor by the step amount
  55715. * If the step amount is greater than one, an exception is thrown
  55716. * @param step The amount to move the cursor
  55717. * @returns This path cursor
  55718. */
  55719. move(step: number): PathCursor;
  55720. /**
  55721. * Ensures that the value is limited between zero and one
  55722. * @returns This path cursor
  55723. */
  55724. private ensureLimits;
  55725. /**
  55726. * Runs onchange callbacks on change (used by the animation engine)
  55727. * @returns This path cursor
  55728. */
  55729. private raiseOnChange;
  55730. /**
  55731. * Executes a function on change
  55732. * @param f A path cursor onchange callback
  55733. * @returns This path cursor
  55734. */
  55735. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55736. }
  55737. }
  55738. declare module BABYLON {
  55739. /** @hidden */
  55740. export var blurPixelShader: {
  55741. name: string;
  55742. shader: string;
  55743. };
  55744. }
  55745. declare module BABYLON {
  55746. /** @hidden */
  55747. export var bones300Declaration: {
  55748. name: string;
  55749. shader: string;
  55750. };
  55751. }
  55752. declare module BABYLON {
  55753. /** @hidden */
  55754. export var instances300Declaration: {
  55755. name: string;
  55756. shader: string;
  55757. };
  55758. }
  55759. declare module BABYLON {
  55760. /** @hidden */
  55761. export var pointCloudVertexDeclaration: {
  55762. name: string;
  55763. shader: string;
  55764. };
  55765. }
  55766. // Mixins
  55767. interface Window {
  55768. mozIndexedDB: IDBFactory;
  55769. webkitIndexedDB: IDBFactory;
  55770. msIndexedDB: IDBFactory;
  55771. webkitURL: typeof URL;
  55772. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55773. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55774. WebGLRenderingContext: WebGLRenderingContext;
  55775. MSGesture: MSGesture;
  55776. CANNON: any;
  55777. AudioContext: AudioContext;
  55778. webkitAudioContext: AudioContext;
  55779. PointerEvent: any;
  55780. Math: Math;
  55781. Uint8Array: Uint8ArrayConstructor;
  55782. Float32Array: Float32ArrayConstructor;
  55783. mozURL: typeof URL;
  55784. msURL: typeof URL;
  55785. VRFrameData: any; // WebVR, from specs 1.1
  55786. DracoDecoderModule: any;
  55787. setImmediate(handler: (...args: any[]) => void): number;
  55788. }
  55789. interface HTMLCanvasElement {
  55790. requestPointerLock(): void;
  55791. msRequestPointerLock?(): void;
  55792. mozRequestPointerLock?(): void;
  55793. webkitRequestPointerLock?(): void;
  55794. /** Track wether a record is in progress */
  55795. isRecording: boolean;
  55796. /** Capture Stream method defined by some browsers */
  55797. captureStream(fps?: number): MediaStream;
  55798. }
  55799. interface CanvasRenderingContext2D {
  55800. msImageSmoothingEnabled: boolean;
  55801. }
  55802. interface MouseEvent {
  55803. mozMovementX: number;
  55804. mozMovementY: number;
  55805. webkitMovementX: number;
  55806. webkitMovementY: number;
  55807. msMovementX: number;
  55808. msMovementY: number;
  55809. }
  55810. interface Navigator {
  55811. mozGetVRDevices: (any: any) => any;
  55812. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55813. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55814. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55815. webkitGetGamepads(): Gamepad[];
  55816. msGetGamepads(): Gamepad[];
  55817. webkitGamepads(): Gamepad[];
  55818. }
  55819. interface HTMLVideoElement {
  55820. mozSrcObject: any;
  55821. }
  55822. interface Math {
  55823. fround(x: number): number;
  55824. imul(a: number, b: number): number;
  55825. }
  55826. interface WebGLRenderingContext {
  55827. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55828. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55829. vertexAttribDivisor(index: number, divisor: number): void;
  55830. createVertexArray(): any;
  55831. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55832. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55833. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55834. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55835. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55836. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55837. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55838. // Queries
  55839. createQuery(): WebGLQuery;
  55840. deleteQuery(query: WebGLQuery): void;
  55841. beginQuery(target: number, query: WebGLQuery): void;
  55842. endQuery(target: number): void;
  55843. getQueryParameter(query: WebGLQuery, pname: number): any;
  55844. getQuery(target: number, pname: number): any;
  55845. MAX_SAMPLES: number;
  55846. RGBA8: number;
  55847. READ_FRAMEBUFFER: number;
  55848. DRAW_FRAMEBUFFER: number;
  55849. UNIFORM_BUFFER: number;
  55850. HALF_FLOAT_OES: number;
  55851. RGBA16F: number;
  55852. RGBA32F: number;
  55853. R32F: number;
  55854. RG32F: number;
  55855. RGB32F: number;
  55856. R16F: number;
  55857. RG16F: number;
  55858. RGB16F: number;
  55859. RED: number;
  55860. RG: number;
  55861. R8: number;
  55862. RG8: number;
  55863. UNSIGNED_INT_24_8: number;
  55864. DEPTH24_STENCIL8: number;
  55865. /* Multiple Render Targets */
  55866. drawBuffers(buffers: number[]): void;
  55867. readBuffer(src: number): void;
  55868. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55869. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55870. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55871. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55872. // Occlusion Query
  55873. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55874. ANY_SAMPLES_PASSED: number;
  55875. QUERY_RESULT_AVAILABLE: number;
  55876. QUERY_RESULT: number;
  55877. }
  55878. interface WebGLProgram { private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55879. }
  55880. interface EXT_disjoint_timer_query {
  55881. QUERY_COUNTER_BITS_EXT: number;
  55882. TIME_ELAPSED_EXT: number;
  55883. TIMESTAMP_EXT: number;
  55884. GPU_DISJOINT_EXT: number;
  55885. QUERY_RESULT_EXT: number;
  55886. QUERY_RESULT_AVAILABLE_EXT: number;
  55887. queryCounterEXT(query: WebGLQuery, target: number): void;
  55888. createQueryEXT(): WebGLQuery;
  55889. beginQueryEXT(target: number, query: WebGLQuery): void;
  55890. endQueryEXT(target: number): void;
  55891. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55892. deleteQueryEXT(query: WebGLQuery): void;
  55893. }
  55894. interface WebGLUniformLocation { currentState: any;
  55895. }
  55896. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55897. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55898. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55899. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55900. interface WebGLRenderingContext {
  55901. readonly RASTERIZER_DISCARD: number;
  55902. readonly DEPTH_COMPONENT24: number;
  55903. readonly TEXTURE_3D: number;
  55904. readonly TEXTURE_2D_ARRAY: number;
  55905. readonly TEXTURE_COMPARE_FUNC: number;
  55906. readonly TEXTURE_COMPARE_MODE: number;
  55907. readonly COMPARE_REF_TO_TEXTURE: number;
  55908. readonly TEXTURE_WRAP_R: number;
  55909. readonly HALF_FLOAT: number;
  55910. readonly RGB8: number;
  55911. readonly RED_INTEGER: number;
  55912. readonly RG_INTEGER: number;
  55913. readonly RGB_INTEGER: number;
  55914. readonly RGBA_INTEGER: number;
  55915. readonly R8_SNORM: number;
  55916. readonly RG8_SNORM: number;
  55917. readonly RGB8_SNORM: number;
  55918. readonly RGBA8_SNORM: number;
  55919. readonly R8I: number;
  55920. readonly RG8I: number;
  55921. readonly RGB8I: number;
  55922. readonly RGBA8I: number;
  55923. readonly R8UI: number;
  55924. readonly RG8UI: number;
  55925. readonly RGB8UI: number;
  55926. readonly RGBA8UI: number;
  55927. readonly R16I: number;
  55928. readonly RG16I: number;
  55929. readonly RGB16I: number;
  55930. readonly RGBA16I: number;
  55931. readonly R16UI: number;
  55932. readonly RG16UI: number;
  55933. readonly RGB16UI: number;
  55934. readonly RGBA16UI: number;
  55935. readonly R32I: number;
  55936. readonly RG32I: number;
  55937. readonly RGB32I: number;
  55938. readonly RGBA32I: number;
  55939. readonly R32UI: number;
  55940. readonly RG32UI: number;
  55941. readonly RGB32UI: number;
  55942. readonly RGBA32UI: number;
  55943. readonly RGB10_A2UI: number;
  55944. readonly R11F_G11F_B10F: number;
  55945. readonly RGB9_E5: number;
  55946. readonly RGB10_A2: number;
  55947. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55948. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55949. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55950. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55951. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55952. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55953. 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;
  55954. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55955. readonly TRANSFORM_FEEDBACK: number;
  55956. readonly INTERLEAVED_ATTRIBS: number;
  55957. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55958. createTransformFeedback(): WebGLTransformFeedback;
  55959. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55960. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55961. beginTransformFeedback(primitiveMode: number): void;
  55962. endTransformFeedback(): void;
  55963. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55964. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55965. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55966. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55967. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55968. }
  55969. interface ImageBitmap {
  55970. readonly width: number;
  55971. readonly height: number;
  55972. close(): void;
  55973. }
  55974. interface WebGLQuery extends WebGLObject {
  55975. }
  55976. declare var WebGLQuery: {
  55977. prototype: WebGLQuery;
  55978. new(): WebGLQuery;
  55979. };
  55980. interface WebGLSampler extends WebGLObject {
  55981. }
  55982. declare var WebGLSampler: {
  55983. prototype: WebGLSampler;
  55984. new(): WebGLSampler;
  55985. };
  55986. interface WebGLSync extends WebGLObject {
  55987. }
  55988. declare var WebGLSync: {
  55989. prototype: WebGLSync;
  55990. new(): WebGLSync;
  55991. };
  55992. interface WebGLTransformFeedback extends WebGLObject {
  55993. }
  55994. declare var WebGLTransformFeedback: {
  55995. prototype: WebGLTransformFeedback;
  55996. new(): WebGLTransformFeedback;
  55997. };
  55998. interface WebGLVertexArrayObject extends WebGLObject {
  55999. }
  56000. declare var WebGLVertexArrayObject: {
  56001. prototype: WebGLVertexArrayObject;
  56002. new(): WebGLVertexArrayObject;
  56003. };
  56004. // Type definitions for WebVR API
  56005. // Project: https://w3c.github.io/webvr/
  56006. // Definitions by: six a <https://github.com/lostfictions>
  56007. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56008. interface VRDisplay extends EventTarget {
  56009. /**
  56010. * Dictionary of capabilities describing the VRDisplay.
  56011. */
  56012. readonly capabilities: VRDisplayCapabilities;
  56013. /**
  56014. * z-depth defining the far plane of the eye view frustum
  56015. * enables mapping of values in the render target depth
  56016. * attachment to scene coordinates. Initially set to 10000.0.
  56017. */
  56018. depthFar: number;
  56019. /**
  56020. * z-depth defining the near plane of the eye view frustum
  56021. * enables mapping of values in the render target depth
  56022. * attachment to scene coordinates. Initially set to 0.01.
  56023. */
  56024. depthNear: number;
  56025. /**
  56026. * An identifier for this distinct VRDisplay. Used as an
  56027. * association point in the Gamepad API.
  56028. */
  56029. readonly displayId: number;
  56030. /**
  56031. * A display name, a user-readable name identifying it.
  56032. */
  56033. readonly displayName: string;
  56034. readonly isConnected: boolean;
  56035. readonly isPresenting: boolean;
  56036. /**
  56037. * If this VRDisplay supports room-scale experiences, the optional
  56038. * stage attribute contains details on the room-scale parameters.
  56039. */
  56040. readonly stageParameters: VRStageParameters | null;
  56041. /**
  56042. * Passing the value returned by `requestAnimationFrame` to
  56043. * `cancelAnimationFrame` will unregister the callback.
  56044. * @param handle Define the hanle of the request to cancel
  56045. */
  56046. cancelAnimationFrame(handle: number): void;
  56047. /**
  56048. * Stops presenting to the VRDisplay.
  56049. * @returns a promise to know when it stopped
  56050. */
  56051. exitPresent(): Promise<void>;
  56052. /**
  56053. * Return the current VREyeParameters for the given eye.
  56054. * @param whichEye Define the eye we want the parameter for
  56055. * @returns the eye parameters
  56056. */
  56057. getEyeParameters(whichEye: string): VREyeParameters;
  56058. /**
  56059. * Populates the passed VRFrameData with the information required to render
  56060. * the current frame.
  56061. * @param frameData Define the data structure to populate
  56062. * @returns true if ok otherwise false
  56063. */
  56064. getFrameData(frameData: VRFrameData): boolean;
  56065. /**
  56066. * Get the layers currently being presented.
  56067. * @returns the list of VR layers
  56068. */
  56069. getLayers(): VRLayer[];
  56070. /**
  56071. * Return a VRPose containing the future predicted pose of the VRDisplay
  56072. * when the current frame will be presented. The value returned will not
  56073. * change until JavaScript has returned control to the browser.
  56074. *
  56075. * The VRPose will contain the position, orientation, velocity,
  56076. * and acceleration of each of these properties.
  56077. * @returns the pose object
  56078. */
  56079. getPose(): VRPose;
  56080. /**
  56081. * Return the current instantaneous pose of the VRDisplay, with no
  56082. * prediction applied.
  56083. * @returns the current instantaneous pose
  56084. */
  56085. getImmediatePose(): VRPose;
  56086. /**
  56087. * The callback passed to `requestAnimationFrame` will be called
  56088. * any time a new frame should be rendered. When the VRDisplay is
  56089. * presenting the callback will be called at the native refresh
  56090. * rate of the HMD. When not presenting this function acts
  56091. * identically to how window.requestAnimationFrame acts. Content should
  56092. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56093. * asynchronously from other displays and at differing refresh rates.
  56094. * @param callback Define the eaction to run next frame
  56095. * @returns the request handle it
  56096. */
  56097. requestAnimationFrame(callback: FrameRequestCallback): number;
  56098. /**
  56099. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56100. * Repeat calls while already presenting will update the VRLayers being displayed.
  56101. * @param layers Define the list of layer to present
  56102. * @returns a promise to know when the request has been fulfilled
  56103. */
  56104. requestPresent(layers: VRLayer[]): Promise<void>;
  56105. /**
  56106. * Reset the pose for this display, treating its current position and
  56107. * orientation as the "origin/zero" values. VRPose.position,
  56108. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56109. * updated when calling resetPose(). This should be called in only
  56110. * sitting-space experiences.
  56111. */
  56112. resetPose(): void;
  56113. /**
  56114. * The VRLayer provided to the VRDisplay will be captured and presented
  56115. * in the HMD. Calling this function has the same effect on the source
  56116. * canvas as any other operation that uses its source image, and canvases
  56117. * created without preserveDrawingBuffer set to true will be cleared.
  56118. * @param pose Define the pose to submit
  56119. */
  56120. submitFrame(pose?: VRPose): void;
  56121. }
  56122. declare var VRDisplay: {
  56123. prototype: VRDisplay;
  56124. new(): VRDisplay;
  56125. };
  56126. interface VRLayer {
  56127. leftBounds?: number[] | Float32Array | null;
  56128. rightBounds?: number[] | Float32Array | null;
  56129. source?: HTMLCanvasElement | null;
  56130. }
  56131. interface VRDisplayCapabilities {
  56132. readonly canPresent: boolean;
  56133. readonly hasExternalDisplay: boolean;
  56134. readonly hasOrientation: boolean;
  56135. readonly hasPosition: boolean;
  56136. readonly maxLayers: number;
  56137. }
  56138. interface VREyeParameters {
  56139. /** @deprecated */
  56140. readonly fieldOfView: VRFieldOfView;
  56141. readonly offset: Float32Array;
  56142. readonly renderHeight: number;
  56143. readonly renderWidth: number;
  56144. }
  56145. interface VRFieldOfView {
  56146. readonly downDegrees: number;
  56147. readonly leftDegrees: number;
  56148. readonly rightDegrees: number;
  56149. readonly upDegrees: number;
  56150. }
  56151. interface VRFrameData {
  56152. readonly leftProjectionMatrix: Float32Array;
  56153. readonly leftViewMatrix: Float32Array;
  56154. readonly pose: VRPose;
  56155. readonly rightProjectionMatrix: Float32Array;
  56156. readonly rightViewMatrix: Float32Array;
  56157. readonly timestamp: number;
  56158. }
  56159. interface VRPose {
  56160. readonly angularAcceleration: Float32Array | null;
  56161. readonly angularVelocity: Float32Array | null;
  56162. readonly linearAcceleration: Float32Array | null;
  56163. readonly linearVelocity: Float32Array | null;
  56164. readonly orientation: Float32Array | null;
  56165. readonly position: Float32Array | null;
  56166. readonly timestamp: number;
  56167. }
  56168. interface VRStageParameters {
  56169. sittingToStandingTransform?: Float32Array;
  56170. sizeX?: number;
  56171. sizeY?: number;
  56172. }
  56173. interface Navigator {
  56174. getVRDisplays(): Promise<VRDisplay[]>;
  56175. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56176. }
  56177. interface Window {
  56178. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56179. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56180. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56181. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56182. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56183. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56184. }
  56185. interface Gamepad {
  56186. readonly displayId: number;
  56187. }
  56188. interface XRDevice {
  56189. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56190. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56191. }
  56192. interface XRSession {
  56193. getInputSources(): Array<any>;
  56194. baseLayer: XRWebGLLayer;
  56195. requestFrameOfReference(type: string): Promise<void>;
  56196. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56197. end(): Promise<void>;
  56198. requestAnimationFrame: Function;
  56199. addEventListener: Function;
  56200. }
  56201. interface XRSessionCreationOptions {
  56202. outputContext?: WebGLRenderingContext | null;
  56203. immersive?: boolean;
  56204. environmentIntegration?: boolean;
  56205. }
  56206. interface XRLayer {
  56207. getViewport: Function;
  56208. framebufferWidth: number;
  56209. framebufferHeight: number;
  56210. }
  56211. interface XRView {
  56212. projectionMatrix: Float32Array;
  56213. }
  56214. interface XRFrame {
  56215. getDevicePose: Function;
  56216. getInputPose: Function;
  56217. views: Array<XRView>;
  56218. baseLayer: XRLayer;
  56219. }
  56220. interface XRFrameOfReference {
  56221. }
  56222. interface XRWebGLLayer extends XRLayer {
  56223. framebuffer: WebGLFramebuffer;
  56224. }
  56225. declare var XRWebGLLayer: {
  56226. prototype: XRWebGLLayer;
  56227. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56228. };
  56229. declare module BABYLON.GUI {
  56230. /**
  56231. * Class used to specific a value and its associated unit
  56232. */
  56233. export class ValueAndUnit {
  56234. /** defines the unit to store */
  56235. unit: number;
  56236. /** defines a boolean indicating if the value can be negative */
  56237. negativeValueAllowed: boolean;
  56238. private _value;
  56239. private _originalUnit;
  56240. /**
  56241. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  56242. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56243. */
  56244. ignoreAdaptiveScaling: boolean;
  56245. /**
  56246. * Creates a new ValueAndUnit
  56247. * @param value defines the value to store
  56248. * @param unit defines the unit to store
  56249. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  56250. */
  56251. constructor(value: number,
  56252. /** defines the unit to store */
  56253. unit?: number,
  56254. /** defines a boolean indicating if the value can be negative */
  56255. negativeValueAllowed?: boolean);
  56256. /** Gets a boolean indicating if the value is a percentage */
  56257. readonly isPercentage: boolean;
  56258. /** Gets a boolean indicating if the value is store as pixel */
  56259. readonly isPixel: boolean;
  56260. /** Gets direct internal value */
  56261. readonly internalValue: number;
  56262. /**
  56263. * Gets value as pixel
  56264. * @param host defines the root host
  56265. * @param refValue defines the reference value for percentages
  56266. * @returns the value as pixel
  56267. */
  56268. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  56269. /**
  56270. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  56271. * @param value defines the value to store
  56272. * @param unit defines the unit to store
  56273. * @returns the current ValueAndUnit
  56274. */
  56275. updateInPlace(value: number, unit?: number): ValueAndUnit;
  56276. /**
  56277. * Gets the value accordingly to its unit
  56278. * @param host defines the root host
  56279. * @returns the value
  56280. */
  56281. getValue(host: AdvancedDynamicTexture): number;
  56282. /**
  56283. * Gets a string representation of the value
  56284. * @param host defines the root host
  56285. * @param decimals defines an optional number of decimals to display
  56286. * @returns a string
  56287. */
  56288. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  56289. /**
  56290. * Store a value parsed from a string
  56291. * @param source defines the source string
  56292. * @returns true if the value was successfully parsed
  56293. */
  56294. fromString(source: string | number): boolean;
  56295. private static _Regex;
  56296. private static _UNITMODE_PERCENTAGE;
  56297. private static _UNITMODE_PIXEL;
  56298. /** UNITMODE_PERCENTAGE */
  56299. static readonly UNITMODE_PERCENTAGE: number;
  56300. /** UNITMODE_PIXEL */
  56301. static readonly UNITMODE_PIXEL: number;
  56302. }
  56303. }
  56304. declare module BABYLON.GUI {
  56305. /**
  56306. * Define a style used by control to automatically setup properties based on a template.
  56307. * Only support font related properties so far
  56308. */
  56309. export class Style implements BABYLON.IDisposable {
  56310. private _fontFamily;
  56311. private _fontStyle;
  56312. private _fontWeight;
  56313. /** @hidden */ host: AdvancedDynamicTexture;
  56314. /** @hidden */ fontSize: ValueAndUnit;
  56315. /**
  56316. * BABYLON.Observable raised when the style values are changed
  56317. */
  56318. onChangedObservable: BABYLON.Observable<Style>;
  56319. /**
  56320. * Creates a new style object
  56321. * @param host defines the AdvancedDynamicTexture which hosts this style
  56322. */
  56323. constructor(host: AdvancedDynamicTexture);
  56324. /**
  56325. * Gets or sets the font size
  56326. */
  56327. fontSize: string | number;
  56328. /**
  56329. * Gets or sets the font family
  56330. */
  56331. fontFamily: string;
  56332. /**
  56333. * Gets or sets the font style
  56334. */
  56335. fontStyle: string;
  56336. /** Gets or sets font weight */
  56337. fontWeight: string;
  56338. /** Dispose all associated resources */
  56339. dispose(): void;
  56340. }
  56341. }
  56342. declare module BABYLON.GUI {
  56343. /**
  56344. * Class used to transport BABYLON.Vector2 information for pointer events
  56345. */
  56346. export class Vector2WithInfo extends BABYLON.Vector2 {
  56347. /** defines the current mouse button index */
  56348. buttonIndex: number;
  56349. /**
  56350. * Creates a new Vector2WithInfo
  56351. * @param source defines the vector2 data to transport
  56352. * @param buttonIndex defines the current mouse button index
  56353. */
  56354. constructor(source: BABYLON.Vector2,
  56355. /** defines the current mouse button index */
  56356. buttonIndex?: number);
  56357. }
  56358. /** Class used to provide 2D matrix features */
  56359. export class Matrix2D {
  56360. /** Gets the internal array of 6 floats used to store matrix data */
  56361. m: Float32Array;
  56362. /**
  56363. * Creates a new matrix
  56364. * @param m00 defines value for (0, 0)
  56365. * @param m01 defines value for (0, 1)
  56366. * @param m10 defines value for (1, 0)
  56367. * @param m11 defines value for (1, 1)
  56368. * @param m20 defines value for (2, 0)
  56369. * @param m21 defines value for (2, 1)
  56370. */
  56371. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  56372. /**
  56373. * Fills the matrix from direct values
  56374. * @param m00 defines value for (0, 0)
  56375. * @param m01 defines value for (0, 1)
  56376. * @param m10 defines value for (1, 0)
  56377. * @param m11 defines value for (1, 1)
  56378. * @param m20 defines value for (2, 0)
  56379. * @param m21 defines value for (2, 1)
  56380. * @returns the current modified matrix
  56381. */
  56382. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  56383. /**
  56384. * Gets matrix determinant
  56385. * @returns the determinant
  56386. */
  56387. determinant(): number;
  56388. /**
  56389. * Inverses the matrix and stores it in a target matrix
  56390. * @param result defines the target matrix
  56391. * @returns the current matrix
  56392. */
  56393. invertToRef(result: Matrix2D): Matrix2D;
  56394. /**
  56395. * Multiplies the current matrix with another one
  56396. * @param other defines the second operand
  56397. * @param result defines the target matrix
  56398. * @returns the current matrix
  56399. */
  56400. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  56401. /**
  56402. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  56403. * @param x defines the x coordinate to transform
  56404. * @param y defines the x coordinate to transform
  56405. * @param result defines the target vector2
  56406. * @returns the current matrix
  56407. */
  56408. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  56409. /**
  56410. * Creates an identity matrix
  56411. * @returns a new matrix
  56412. */
  56413. static Identity(): Matrix2D;
  56414. /**
  56415. * Creates a translation matrix and stores it in a target matrix
  56416. * @param x defines the x coordinate of the translation
  56417. * @param y defines the y coordinate of the translation
  56418. * @param result defines the target matrix
  56419. */
  56420. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  56421. /**
  56422. * Creates a scaling matrix and stores it in a target matrix
  56423. * @param x defines the x coordinate of the scaling
  56424. * @param y defines the y coordinate of the scaling
  56425. * @param result defines the target matrix
  56426. */
  56427. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  56428. /**
  56429. * Creates a rotation matrix and stores it in a target matrix
  56430. * @param angle defines the rotation angle
  56431. * @param result defines the target matrix
  56432. */
  56433. static RotationToRef(angle: number, result: Matrix2D): void;
  56434. private static _TempPreTranslationMatrix;
  56435. private static _TempPostTranslationMatrix;
  56436. private static _TempRotationMatrix;
  56437. private static _TempScalingMatrix;
  56438. private static _TempCompose0;
  56439. private static _TempCompose1;
  56440. private static _TempCompose2;
  56441. /**
  56442. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  56443. * @param tx defines the x coordinate of the translation
  56444. * @param ty defines the y coordinate of the translation
  56445. * @param angle defines the rotation angle
  56446. * @param scaleX defines the x coordinate of the scaling
  56447. * @param scaleY defines the y coordinate of the scaling
  56448. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  56449. * @param result defines the target matrix
  56450. */
  56451. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  56452. }
  56453. }
  56454. declare module BABYLON.GUI {
  56455. /**
  56456. * Class used to store 2D control sizes
  56457. */
  56458. export class Measure {
  56459. /** defines left coordinate */
  56460. left: number;
  56461. /** defines top coordinate */
  56462. top: number;
  56463. /** defines width dimension */
  56464. width: number;
  56465. /** defines height dimension */
  56466. height: number;
  56467. /**
  56468. * Creates a new measure
  56469. * @param left defines left coordinate
  56470. * @param top defines top coordinate
  56471. * @param width defines width dimension
  56472. * @param height defines height dimension
  56473. */
  56474. constructor(
  56475. /** defines left coordinate */
  56476. left: number,
  56477. /** defines top coordinate */
  56478. top: number,
  56479. /** defines width dimension */
  56480. width: number,
  56481. /** defines height dimension */
  56482. height: number);
  56483. /**
  56484. * Copy from another measure
  56485. * @param other defines the other measure to copy from
  56486. */
  56487. copyFrom(other: Measure): void;
  56488. /**
  56489. * Copy from a group of 4 floats
  56490. * @param left defines left coordinate
  56491. * @param top defines top coordinate
  56492. * @param width defines width dimension
  56493. * @param height defines height dimension
  56494. */
  56495. copyFromFloats(left: number, top: number, width: number, height: number): void;
  56496. /**
  56497. * Computes the axis aligned bounding box measure for two given measures
  56498. * @param a Input measure
  56499. * @param b Input measure
  56500. * @param result the resulting bounding measure
  56501. */
  56502. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  56503. /**
  56504. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  56505. * @param transform the matrix to transform the measure before computing the AABB
  56506. * @param result the resulting AABB
  56507. */
  56508. transformToRef(transform: Matrix2D, result: Measure): void;
  56509. /**
  56510. * Check equality between this measure and another one
  56511. * @param other defines the other measures
  56512. * @returns true if both measures are equals
  56513. */
  56514. isEqualsTo(other: Measure): boolean;
  56515. /**
  56516. * Creates an empty measure
  56517. * @returns a new measure
  56518. */
  56519. static Empty(): Measure;
  56520. }
  56521. }
  56522. declare module BABYLON.GUI {
  56523. /**
  56524. * Interface used to define a control that can receive focus
  56525. */
  56526. export interface IFocusableControl {
  56527. /**
  56528. * Function called when the control receives the focus
  56529. */
  56530. onFocus(): void;
  56531. /**
  56532. * Function called when the control loses the focus
  56533. */
  56534. onBlur(): void;
  56535. /**
  56536. * Function called to let the control handle keyboard events
  56537. * @param evt defines the current keyboard event
  56538. */
  56539. processKeyboard(evt: KeyboardEvent): void;
  56540. /**
  56541. * Function called to get the list of controls that should not steal the focus from this control
  56542. * @returns an array of controls
  56543. */
  56544. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  56545. }
  56546. /**
  56547. * Class used to create texture to support 2D GUI elements
  56548. * @see http://doc.babylonjs.com/how_to/gui
  56549. */
  56550. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  56551. private _isDirty;
  56552. private _renderObserver;
  56553. private _resizeObserver;
  56554. private _preKeyboardObserver;
  56555. private _pointerMoveObserver;
  56556. private _pointerObserver;
  56557. private _canvasPointerOutObserver;
  56558. private _background;
  56559. /** @hidden */ rootContainer: Container;
  56560. /** @hidden */ lastPickedControl: Control;
  56561. /** @hidden */ lastControlOver: {
  56562. [pointerId: number]: Control;
  56563. };
  56564. /** @hidden */ lastControlDown: {
  56565. [pointerId: number]: Control;
  56566. };
  56567. /** @hidden */ capturingControl: {
  56568. [pointerId: number]: Control;
  56569. };
  56570. /** @hidden */ shouldBlockPointer: boolean;
  56571. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  56572. /** @hidden */ linkedControls: Control[];
  56573. private _isFullscreen;
  56574. private _fullscreenViewport;
  56575. private _idealWidth;
  56576. private _idealHeight;
  56577. private _useSmallestIdeal;
  56578. private _renderAtIdealSize;
  56579. private _focusedControl;
  56580. private _blockNextFocusCheck;
  56581. private _renderScale;
  56582. private _rootCanvas;
  56583. private _cursorChanged;
  56584. /**
  56585. * Define type to string to ensure compatibility across browsers
  56586. * Safari doesn't support DataTransfer constructor
  56587. */
  56588. private _clipboardData;
  56589. /**
  56590. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  56591. */
  56592. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  56593. /**
  56594. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  56595. */
  56596. onControlPickedObservable: BABYLON.Observable<Control>;
  56597. /**
  56598. * BABYLON.Observable event triggered before layout is evaluated
  56599. */
  56600. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56601. /**
  56602. * BABYLON.Observable event triggered after the layout was evaluated
  56603. */
  56604. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56605. /**
  56606. * BABYLON.Observable event triggered before the texture is rendered
  56607. */
  56608. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56609. /**
  56610. * BABYLON.Observable event triggered after the texture was rendered
  56611. */
  56612. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56613. /**
  56614. * Gets or sets a boolean defining if alpha is stored as premultiplied
  56615. */
  56616. premulAlpha: boolean;
  56617. /**
  56618. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  56619. * Useful when you want more antialiasing
  56620. */
  56621. renderScale: number;
  56622. /** Gets or sets the background color */
  56623. background: string;
  56624. /**
  56625. * Gets or sets the ideal width used to design controls.
  56626. * The GUI will then rescale everything accordingly
  56627. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56628. */
  56629. idealWidth: number;
  56630. /**
  56631. * Gets or sets the ideal height used to design controls.
  56632. * The GUI will then rescale everything accordingly
  56633. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56634. */
  56635. idealHeight: number;
  56636. /**
  56637. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  56638. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56639. */
  56640. useSmallestIdeal: boolean;
  56641. /**
  56642. * Gets or sets a boolean indicating if adaptive scaling must be used
  56643. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56644. */
  56645. renderAtIdealSize: boolean;
  56646. /**
  56647. * Gets the underlying layer used to render the texture when in fullscreen mode
  56648. */
  56649. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  56650. /**
  56651. * Gets the root container control
  56652. */
  56653. readonly rootContainer: Container;
  56654. /**
  56655. * Returns an array containing the root container.
  56656. * This is mostly used to let the Inspector introspects the ADT
  56657. * @returns an array containing the rootContainer
  56658. */
  56659. getChildren(): Array<Container>;
  56660. /**
  56661. * Will return all controls that are inside this texture
  56662. * @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
  56663. * @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
  56664. * @return all child controls
  56665. */
  56666. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56667. /**
  56668. * Gets or sets the current focused control
  56669. */
  56670. focusedControl: BABYLON.Nullable<IFocusableControl>;
  56671. /**
  56672. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  56673. */
  56674. isForeground: boolean;
  56675. /**
  56676. * Gets or set information about clipboardData
  56677. */
  56678. clipboardData: string;
  56679. /**
  56680. * Creates a new AdvancedDynamicTexture
  56681. * @param name defines the name of the texture
  56682. * @param width defines the width of the texture
  56683. * @param height defines the height of the texture
  56684. * @param scene defines the hosting scene
  56685. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  56686. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  56687. */
  56688. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  56689. /**
  56690. * Get the current class name of the texture useful for serialization or dynamic coding.
  56691. * @returns "AdvancedDynamicTexture"
  56692. */
  56693. getClassName(): string;
  56694. /**
  56695. * Function used to execute a function on all controls
  56696. * @param func defines the function to execute
  56697. * @param container defines the container where controls belong. If null the root container will be used
  56698. */
  56699. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  56700. private _useInvalidateRectOptimization;
  56701. /**
  56702. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  56703. */
  56704. useInvalidateRectOptimization: boolean;
  56705. private _invalidatedRectangle;
  56706. /**
  56707. * Invalidates a rectangle area on the gui texture
  56708. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  56709. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  56710. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  56711. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  56712. */
  56713. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  56714. /**
  56715. * Marks the texture as dirty forcing a complete update
  56716. */
  56717. markAsDirty(): void;
  56718. /**
  56719. * Helper function used to create a new style
  56720. * @returns a new style
  56721. * @see http://doc.babylonjs.com/how_to/gui#styles
  56722. */
  56723. createStyle(): Style;
  56724. /**
  56725. * Adds a new control to the root container
  56726. * @param control defines the control to add
  56727. * @returns the current texture
  56728. */
  56729. addControl(control: Control): AdvancedDynamicTexture;
  56730. /**
  56731. * Removes a control from the root container
  56732. * @param control defines the control to remove
  56733. * @returns the current texture
  56734. */
  56735. removeControl(control: Control): AdvancedDynamicTexture;
  56736. /**
  56737. * Release all resources
  56738. */
  56739. dispose(): void;
  56740. private _onResize;
  56741. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  56742. /**
  56743. * Get screen coordinates for a vector3
  56744. * @param position defines the position to project
  56745. * @param worldMatrix defines the world matrix to use
  56746. * @returns the projected position
  56747. */
  56748. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  56749. private _checkUpdate;
  56750. private _clearMeasure;
  56751. private _render;
  56752. /** @hidden */ changeCursor(cursor: string): void;
  56753. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  56754. private _doPicking;
  56755. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  56756. [pointerId: number]: Control;
  56757. }, control: Control): void;
  56758. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  56759. /** Attach to all scene events required to support pointer events */
  56760. attach(): void;
  56761. /** @hidden */
  56762. private onClipboardCopy;
  56763. /** @hidden */
  56764. private onClipboardCut;
  56765. /** @hidden */
  56766. private onClipboardPaste;
  56767. /**
  56768. * Register the clipboard Events onto the canvas
  56769. */
  56770. registerClipboardEvents(): void;
  56771. /**
  56772. * Unregister the clipboard Events from the canvas
  56773. */
  56774. unRegisterClipboardEvents(): void;
  56775. /**
  56776. * Connect the texture to a hosting mesh to enable interactions
  56777. * @param mesh defines the mesh to attach to
  56778. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  56779. */
  56780. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  56781. /**
  56782. * Move the focus to a specific control
  56783. * @param control defines the control which will receive the focus
  56784. */
  56785. moveFocusToControl(control: IFocusableControl): void;
  56786. private _manageFocus;
  56787. private _attachToOnPointerOut;
  56788. /**
  56789. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  56790. * @param mesh defines the mesh which will receive the texture
  56791. * @param width defines the texture width (1024 by default)
  56792. * @param height defines the texture height (1024 by default)
  56793. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  56794. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  56795. * @returns a new AdvancedDynamicTexture
  56796. */
  56797. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  56798. /**
  56799. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  56800. * In this mode the texture will rely on a layer for its rendering.
  56801. * This allows it to be treated like any other layer.
  56802. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  56803. * LayerMask is set through advancedTexture.layer.layerMask
  56804. * @param name defines name for the texture
  56805. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  56806. * @param scene defines the hsoting scene
  56807. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  56808. * @returns a new AdvancedDynamicTexture
  56809. */
  56810. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  56811. }
  56812. }
  56813. declare module BABYLON.GUI {
  56814. /**
  56815. * Root class used for all 2D controls
  56816. * @see http://doc.babylonjs.com/how_to/gui#controls
  56817. */
  56818. export class Control {
  56819. /** defines the name of the control */
  56820. name?: string | undefined;
  56821. /**
  56822. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  56823. */
  56824. static AllowAlphaInheritance: boolean;
  56825. private _alpha;
  56826. private _alphaSet;
  56827. private _zIndex;
  56828. /** @hidden */ host: AdvancedDynamicTexture;
  56829. /** Gets or sets the control parent */
  56830. parent: BABYLON.Nullable<Container>;
  56831. /** @hidden */ currentMeasure: Measure;
  56832. private _fontFamily;
  56833. private _fontStyle;
  56834. private _fontWeight;
  56835. private _fontSize;
  56836. private _font;
  56837. /** @hidden */ width: ValueAndUnit;
  56838. /** @hidden */ height: ValueAndUnit;
  56839. /** @hidden */
  56840. protected _fontOffset: {
  56841. ascent: number;
  56842. height: number;
  56843. descent: number;
  56844. };
  56845. private _color;
  56846. private _style;
  56847. private _styleObserver;
  56848. /** @hidden */
  56849. protected _horizontalAlignment: number;
  56850. /** @hidden */
  56851. protected _verticalAlignment: number;
  56852. /** @hidden */
  56853. protected _isDirty: boolean;
  56854. /** @hidden */
  56855. protected _wasDirty: boolean;
  56856. /** @hidden */ tempParentMeasure: Measure;
  56857. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  56858. /** @hidden */
  56859. protected _cachedParentMeasure: Measure;
  56860. private _paddingLeft;
  56861. private _paddingRight;
  56862. private _paddingTop;
  56863. private _paddingBottom;
  56864. /** @hidden */ left: ValueAndUnit;
  56865. /** @hidden */ top: ValueAndUnit;
  56866. private _scaleX;
  56867. private _scaleY;
  56868. private _rotation;
  56869. private _transformCenterX;
  56870. private _transformCenterY;
  56871. /** @hidden */ transformMatrix: Matrix2D;
  56872. /** @hidden */
  56873. protected _invertTransformMatrix: Matrix2D;
  56874. /** @hidden */
  56875. protected _transformedPosition: BABYLON.Vector2;
  56876. private _isMatrixDirty;
  56877. private _cachedOffsetX;
  56878. private _cachedOffsetY;
  56879. private _isVisible;
  56880. private _isHighlighted;
  56881. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56882. private _fontSet;
  56883. private _dummyVector2;
  56884. private _downCount;
  56885. private _enterCount;
  56886. private _doNotRender;
  56887. private _downPointerIds;
  56888. protected _isEnabled: boolean;
  56889. protected _disabledColor: string;
  56890. /** @hidden */
  56891. protected _rebuildLayout: boolean;
  56892. /** @hidden */ isClipped: boolean;
  56893. /** @hidden */ tag: any;
  56894. /**
  56895. * 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
  56896. */
  56897. uniqueId: number;
  56898. /**
  56899. * Gets or sets an object used to store user defined information for the node
  56900. */
  56901. metadata: any;
  56902. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  56903. isHitTestVisible: boolean;
  56904. /** Gets or sets a boolean indicating if the control can block pointer events */
  56905. isPointerBlocker: boolean;
  56906. /** Gets or sets a boolean indicating if the control can be focusable */
  56907. isFocusInvisible: boolean;
  56908. /**
  56909. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  56910. * 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
  56911. */
  56912. clipChildren: boolean;
  56913. /**
  56914. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  56915. */
  56916. useBitmapCache: boolean;
  56917. private _cacheData;
  56918. private _shadowOffsetX;
  56919. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  56920. shadowOffsetX: number;
  56921. private _shadowOffsetY;
  56922. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  56923. shadowOffsetY: number;
  56924. private _shadowBlur;
  56925. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  56926. shadowBlur: number;
  56927. private _shadowColor;
  56928. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  56929. shadowColor: string;
  56930. /** Gets or sets the cursor to use when the control is hovered */
  56931. hoverCursor: string;
  56932. /** @hidden */
  56933. protected _linkOffsetX: ValueAndUnit;
  56934. /** @hidden */
  56935. protected _linkOffsetY: ValueAndUnit;
  56936. /** Gets the control type name */
  56937. readonly typeName: string;
  56938. /**
  56939. * Get the current class name of the control.
  56940. * @returns current class name
  56941. */
  56942. getClassName(): string;
  56943. /**
  56944. * An event triggered when the pointer move over the control.
  56945. */
  56946. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  56947. /**
  56948. * An event triggered when the pointer move out of the control.
  56949. */
  56950. onPointerOutObservable: BABYLON.Observable<Control>;
  56951. /**
  56952. * An event triggered when the pointer taps the control
  56953. */
  56954. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  56955. /**
  56956. * An event triggered when pointer up
  56957. */
  56958. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  56959. /**
  56960. * An event triggered when a control is clicked on
  56961. */
  56962. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  56963. /**
  56964. * An event triggered when pointer enters the control
  56965. */
  56966. onPointerEnterObservable: BABYLON.Observable<Control>;
  56967. /**
  56968. * An event triggered when the control is marked as dirty
  56969. */
  56970. onDirtyObservable: BABYLON.Observable<Control>;
  56971. /**
  56972. * An event triggered before drawing the control
  56973. */
  56974. onBeforeDrawObservable: BABYLON.Observable<Control>;
  56975. /**
  56976. * An event triggered after the control was drawn
  56977. */
  56978. onAfterDrawObservable: BABYLON.Observable<Control>;
  56979. /**
  56980. * Get the hosting AdvancedDynamicTexture
  56981. */
  56982. readonly host: AdvancedDynamicTexture;
  56983. /** Gets or set information about font offsets (used to render and align text) */
  56984. fontOffset: {
  56985. ascent: number;
  56986. height: number;
  56987. descent: number;
  56988. };
  56989. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  56990. alpha: number;
  56991. /**
  56992. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  56993. */
  56994. isHighlighted: boolean;
  56995. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  56996. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56997. */
  56998. scaleX: number;
  56999. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  57000. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57001. */
  57002. scaleY: number;
  57003. /** Gets or sets the rotation angle (0 by default)
  57004. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57005. */
  57006. rotation: number;
  57007. /** Gets or sets the transformation center on Y axis (0 by default)
  57008. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57009. */
  57010. transformCenterY: number;
  57011. /** Gets or sets the transformation center on X axis (0 by default)
  57012. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57013. */
  57014. transformCenterX: number;
  57015. /**
  57016. * Gets or sets the horizontal alignment
  57017. * @see http://doc.babylonjs.com/how_to/gui#alignments
  57018. */
  57019. horizontalAlignment: number;
  57020. /**
  57021. * Gets or sets the vertical alignment
  57022. * @see http://doc.babylonjs.com/how_to/gui#alignments
  57023. */
  57024. verticalAlignment: number;
  57025. /**
  57026. * Gets or sets control width
  57027. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57028. */
  57029. width: string | number;
  57030. /**
  57031. * Gets control width in pixel
  57032. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57033. */
  57034. readonly widthInPixels: number;
  57035. /**
  57036. * Gets or sets control height
  57037. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57038. */
  57039. height: string | number;
  57040. /**
  57041. * Gets control height in pixel
  57042. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57043. */
  57044. readonly heightInPixels: number;
  57045. /** Gets or set font family */
  57046. fontFamily: string;
  57047. /** Gets or sets font style */
  57048. fontStyle: string;
  57049. /** Gets or sets font weight */
  57050. fontWeight: string;
  57051. /**
  57052. * Gets or sets style
  57053. * @see http://doc.babylonjs.com/how_to/gui#styles
  57054. */
  57055. style: BABYLON.Nullable<Style>;
  57056. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  57057. /** Gets font size in pixels */
  57058. readonly fontSizeInPixels: number;
  57059. /** Gets or sets font size */
  57060. fontSize: string | number;
  57061. /** Gets or sets foreground color */
  57062. color: string;
  57063. /** Gets or sets z index which is used to reorder controls on the z axis */
  57064. zIndex: number;
  57065. /** Gets or sets a boolean indicating if the control can be rendered */
  57066. notRenderable: boolean;
  57067. /** Gets or sets a boolean indicating if the control is visible */
  57068. isVisible: boolean;
  57069. /** Gets a boolean indicating that the control needs to update its rendering */
  57070. readonly isDirty: boolean;
  57071. /**
  57072. * Gets the current linked mesh (or null if none)
  57073. */
  57074. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  57075. /**
  57076. * Gets or sets a value indicating the padding to use on the left of the control
  57077. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57078. */
  57079. paddingLeft: string | number;
  57080. /**
  57081. * Gets a value indicating the padding in pixels to use on the left of the control
  57082. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57083. */
  57084. readonly paddingLeftInPixels: number;
  57085. /**
  57086. * Gets or sets a value indicating the padding to use on the right of the control
  57087. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57088. */
  57089. paddingRight: string | number;
  57090. /**
  57091. * Gets a value indicating the padding in pixels to use on the right of the control
  57092. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57093. */
  57094. readonly paddingRightInPixels: number;
  57095. /**
  57096. * Gets or sets a value indicating the padding to use on the top of the control
  57097. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57098. */
  57099. paddingTop: string | number;
  57100. /**
  57101. * Gets a value indicating the padding in pixels to use on the top of the control
  57102. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57103. */
  57104. readonly paddingTopInPixels: number;
  57105. /**
  57106. * Gets or sets a value indicating the padding to use on the bottom of the control
  57107. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57108. */
  57109. paddingBottom: string | number;
  57110. /**
  57111. * Gets a value indicating the padding in pixels to use on the bottom of the control
  57112. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57113. */
  57114. readonly paddingBottomInPixels: number;
  57115. /**
  57116. * Gets or sets a value indicating the left coordinate of the control
  57117. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57118. */
  57119. left: string | number;
  57120. /**
  57121. * Gets a value indicating the left coordinate in pixels of the control
  57122. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57123. */
  57124. readonly leftInPixels: number;
  57125. /**
  57126. * Gets or sets a value indicating the top coordinate of the control
  57127. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57128. */
  57129. top: string | number;
  57130. /**
  57131. * Gets a value indicating the top coordinate in pixels of the control
  57132. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57133. */
  57134. readonly topInPixels: number;
  57135. /**
  57136. * Gets or sets a value indicating the offset on X axis to the linked mesh
  57137. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57138. */
  57139. linkOffsetX: string | number;
  57140. /**
  57141. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  57142. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57143. */
  57144. readonly linkOffsetXInPixels: number;
  57145. /**
  57146. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  57147. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57148. */
  57149. linkOffsetY: string | number;
  57150. /**
  57151. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  57152. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57153. */
  57154. readonly linkOffsetYInPixels: number;
  57155. /** Gets the center coordinate on X axis */
  57156. readonly centerX: number;
  57157. /** Gets the center coordinate on Y axis */
  57158. readonly centerY: number;
  57159. /** Gets or sets if control is Enabled*/
  57160. isEnabled: boolean;
  57161. /** Gets or sets background color of control if it's disabled*/
  57162. disabledColor: string;
  57163. /**
  57164. * Creates a new control
  57165. * @param name defines the name of the control
  57166. */
  57167. constructor(
  57168. /** defines the name of the control */
  57169. name?: string | undefined);
  57170. /** @hidden */
  57171. protected _getTypeName(): string;
  57172. /**
  57173. * Gets the first ascendant in the hierarchy of the given type
  57174. * @param className defines the required type
  57175. * @returns the ascendant or null if not found
  57176. */
  57177. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  57178. /** @hidden */ resetFontCache(): void;
  57179. /**
  57180. * Determines if a container is an ascendant of the current control
  57181. * @param container defines the container to look for
  57182. * @returns true if the container is one of the ascendant of the control
  57183. */
  57184. isAscendant(container: Control): boolean;
  57185. /**
  57186. * Gets coordinates in local control space
  57187. * @param globalCoordinates defines the coordinates to transform
  57188. * @returns the new coordinates in local space
  57189. */
  57190. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57191. /**
  57192. * Gets coordinates in local control space
  57193. * @param globalCoordinates defines the coordinates to transform
  57194. * @param result defines the target vector2 where to store the result
  57195. * @returns the current control
  57196. */
  57197. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  57198. /**
  57199. * Gets coordinates in parent local control space
  57200. * @param globalCoordinates defines the coordinates to transform
  57201. * @returns the new coordinates in parent local space
  57202. */
  57203. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57204. /**
  57205. * Move the current control to a vector3 position projected onto the screen.
  57206. * @param position defines the target position
  57207. * @param scene defines the hosting scene
  57208. */
  57209. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  57210. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57211. /**
  57212. * Will return all controls that have this control as ascendant
  57213. * @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
  57214. * @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
  57215. * @return all child controls
  57216. */
  57217. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  57218. /**
  57219. * Link current control with a target mesh
  57220. * @param mesh defines the mesh to link with
  57221. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57222. */
  57223. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  57224. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  57225. /** @hidden */ offsetLeft(offset: number): void;
  57226. /** @hidden */ offsetTop(offset: number): void;
  57227. /** @hidden */ markMatrixAsDirty(): void;
  57228. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  57229. /** @hidden */ intersectsRect(rect: Measure): boolean;
  57230. /** @hidden */
  57231. protected invalidateRect(): void;
  57232. /** @hidden */ markAsDirty(force?: boolean): void;
  57233. /** @hidden */ markAllAsDirty(): void;
  57234. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57235. /** @hidden */
  57236. protected _transform(context?: CanvasRenderingContext2D): void;
  57237. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  57238. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  57239. /** @hidden */
  57240. protected _applyStates(context: CanvasRenderingContext2D): void;
  57241. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57242. /** @hidden */
  57243. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57244. protected _evaluateClippingState(parentMeasure: Measure): void;
  57245. /** @hidden */ measure(): void;
  57246. /** @hidden */
  57247. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57248. /** @hidden */
  57249. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57250. /** @hidden */
  57251. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57252. /** @hidden */
  57253. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57254. private static _ClipMeasure;
  57255. private _tmpMeasureA;
  57256. private _clip;
  57257. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  57258. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  57259. /**
  57260. * Tests if a given coordinates belong to the current control
  57261. * @param x defines x coordinate to test
  57262. * @param y defines y coordinate to test
  57263. * @returns true if the coordinates are inside the control
  57264. */
  57265. contains(x: number, y: number): boolean;
  57266. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57267. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  57268. /** @hidden */ onPointerEnter(target: Control): boolean;
  57269. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57270. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57271. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57272. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  57273. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  57274. private _prepareFont;
  57275. /** Releases associated resources */
  57276. dispose(): void;
  57277. private static _HORIZONTAL_ALIGNMENT_LEFT;
  57278. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  57279. private static _HORIZONTAL_ALIGNMENT_CENTER;
  57280. private static _VERTICAL_ALIGNMENT_TOP;
  57281. private static _VERTICAL_ALIGNMENT_BOTTOM;
  57282. private static _VERTICAL_ALIGNMENT_CENTER;
  57283. /** HORIZONTAL_ALIGNMENT_LEFT */
  57284. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  57285. /** HORIZONTAL_ALIGNMENT_RIGHT */
  57286. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  57287. /** HORIZONTAL_ALIGNMENT_CENTER */
  57288. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  57289. /** VERTICAL_ALIGNMENT_TOP */
  57290. static readonly VERTICAL_ALIGNMENT_TOP: number;
  57291. /** VERTICAL_ALIGNMENT_BOTTOM */
  57292. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  57293. /** VERTICAL_ALIGNMENT_CENTER */
  57294. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  57295. private static _FontHeightSizes;
  57296. /** @hidden */ private static _GetFontOffset(font: string): {
  57297. ascent: number;
  57298. height: number;
  57299. descent: number;
  57300. };
  57301. /**
  57302. * Creates a stack panel that can be used to render headers
  57303. * @param control defines the control to associate with the header
  57304. * @param text defines the text of the header
  57305. * @param size defines the size of the header
  57306. * @param options defines options used to configure the header
  57307. * @returns a new StackPanel
  57308. * @ignore
  57309. * @hidden
  57310. */
  57311. static AddHeader: (control: Control, text: string, size: string | number, options: {
  57312. isHorizontal: boolean;
  57313. controlFirst: boolean;
  57314. }) => any;
  57315. /** @hidden */
  57316. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  57317. }
  57318. }
  57319. declare module BABYLON.GUI {
  57320. /**
  57321. * Root class for 2D containers
  57322. * @see http://doc.babylonjs.com/how_to/gui#containers
  57323. */
  57324. export class Container extends Control {
  57325. name?: string | undefined;
  57326. /** @hidden */
  57327. protected _children: Control[];
  57328. /** @hidden */
  57329. protected _measureForChildren: Measure;
  57330. /** @hidden */
  57331. protected _background: string;
  57332. /** @hidden */
  57333. protected _adaptWidthToChildren: boolean;
  57334. /** @hidden */
  57335. protected _adaptHeightToChildren: boolean;
  57336. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  57337. adaptHeightToChildren: boolean;
  57338. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  57339. adaptWidthToChildren: boolean;
  57340. /** Gets or sets background color */
  57341. background: string;
  57342. /** Gets the list of children */
  57343. readonly children: Control[];
  57344. /**
  57345. * Creates a new Container
  57346. * @param name defines the name of the container
  57347. */
  57348. constructor(name?: string | undefined);
  57349. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  57350. /**
  57351. * Gets a child using its name
  57352. * @param name defines the child name to look for
  57353. * @returns the child control if found
  57354. */
  57355. getChildByName(name: string): BABYLON.Nullable<Control>;
  57356. /**
  57357. * Gets a child using its type and its name
  57358. * @param name defines the child name to look for
  57359. * @param type defines the child type to look for
  57360. * @returns the child control if found
  57361. */
  57362. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  57363. /**
  57364. * Search for a specific control in children
  57365. * @param control defines the control to look for
  57366. * @returns true if the control is in child list
  57367. */
  57368. containsControl(control: Control): boolean;
  57369. /**
  57370. * Adds a new control to the current container
  57371. * @param control defines the control to add
  57372. * @returns the current container
  57373. */
  57374. addControl(control: BABYLON.Nullable<Control>): Container;
  57375. /**
  57376. * Removes all controls from the current container
  57377. * @returns the current container
  57378. */
  57379. clearControls(): Container;
  57380. /**
  57381. * Removes a control from the current container
  57382. * @param control defines the control to remove
  57383. * @returns the current container
  57384. */
  57385. removeControl(control: Control): Container;
  57386. /** @hidden */ reOrderControl(control: Control): void;
  57387. /** @hidden */ offsetLeft(offset: number): void;
  57388. /** @hidden */ offsetTop(offset: number): void;
  57389. /** @hidden */ markAllAsDirty(): void;
  57390. /** @hidden */
  57391. protected _localDraw(context: CanvasRenderingContext2D): void;
  57392. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57393. /** @hidden */
  57394. protected _beforeLayout(): void;
  57395. /** @hidden */
  57396. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57397. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57398. protected _postMeasure(): void;
  57399. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  57400. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57401. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57402. /** @hidden */
  57403. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57404. /** Releases associated resources */
  57405. dispose(): void;
  57406. }
  57407. }
  57408. declare module BABYLON.GUI {
  57409. /** Class used to create rectangle container */
  57410. export class Rectangle extends Container {
  57411. name?: string | undefined;
  57412. private _thickness;
  57413. private _cornerRadius;
  57414. /** Gets or sets border thickness */
  57415. thickness: number;
  57416. /** Gets or sets the corner radius angle */
  57417. cornerRadius: number;
  57418. /**
  57419. * Creates a new Rectangle
  57420. * @param name defines the control name
  57421. */
  57422. constructor(name?: string | undefined);
  57423. protected _getTypeName(): string;
  57424. protected _localDraw(context: CanvasRenderingContext2D): void;
  57425. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57426. private _drawRoundedRect;
  57427. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57428. }
  57429. }
  57430. declare module BABYLON.GUI {
  57431. /**
  57432. * Enum that determines the text-wrapping mode to use.
  57433. */
  57434. export enum TextWrapping {
  57435. /**
  57436. * Clip the text when it's larger than Control.width; this is the default mode.
  57437. */
  57438. Clip = 0,
  57439. /**
  57440. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  57441. */
  57442. WordWrap = 1,
  57443. /**
  57444. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  57445. */
  57446. Ellipsis = 2
  57447. }
  57448. /**
  57449. * Class used to create text block control
  57450. */
  57451. export class TextBlock extends Control {
  57452. /**
  57453. * Defines the name of the control
  57454. */
  57455. name?: string | undefined;
  57456. private _text;
  57457. private _textWrapping;
  57458. private _textHorizontalAlignment;
  57459. private _textVerticalAlignment;
  57460. private _lines;
  57461. private _resizeToFit;
  57462. private _lineSpacing;
  57463. private _outlineWidth;
  57464. private _outlineColor;
  57465. /**
  57466. * An event triggered after the text is changed
  57467. */
  57468. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  57469. /**
  57470. * An event triggered after the text was broken up into lines
  57471. */
  57472. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  57473. /**
  57474. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  57475. */
  57476. readonly lines: any[];
  57477. /**
  57478. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57479. */
  57480. /**
  57481. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57482. */
  57483. resizeToFit: boolean;
  57484. /**
  57485. * Gets or sets a boolean indicating if text must be wrapped
  57486. */
  57487. /**
  57488. * Gets or sets a boolean indicating if text must be wrapped
  57489. */
  57490. textWrapping: TextWrapping | boolean;
  57491. /**
  57492. * Gets or sets text to display
  57493. */
  57494. /**
  57495. * Gets or sets text to display
  57496. */
  57497. text: string;
  57498. /**
  57499. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57500. */
  57501. /**
  57502. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57503. */
  57504. textHorizontalAlignment: number;
  57505. /**
  57506. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57507. */
  57508. /**
  57509. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57510. */
  57511. textVerticalAlignment: number;
  57512. /**
  57513. * Gets or sets line spacing value
  57514. */
  57515. /**
  57516. * Gets or sets line spacing value
  57517. */
  57518. lineSpacing: string | number;
  57519. /**
  57520. * Gets or sets outlineWidth of the text to display
  57521. */
  57522. /**
  57523. * Gets or sets outlineWidth of the text to display
  57524. */
  57525. outlineWidth: number;
  57526. /**
  57527. * Gets or sets outlineColor of the text to display
  57528. */
  57529. /**
  57530. * Gets or sets outlineColor of the text to display
  57531. */
  57532. outlineColor: string;
  57533. /**
  57534. * Creates a new TextBlock object
  57535. * @param name defines the name of the control
  57536. * @param text defines the text to display (emptry string by default)
  57537. */
  57538. constructor(
  57539. /**
  57540. * Defines the name of the control
  57541. */
  57542. name?: string | undefined, text?: string);
  57543. protected _getTypeName(): string;
  57544. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57545. private _drawText;
  57546. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57547. protected _applyStates(context: CanvasRenderingContext2D): void;
  57548. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  57549. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  57550. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  57551. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  57552. protected _renderLines(context: CanvasRenderingContext2D): void;
  57553. /**
  57554. * Given a width constraint applied on the text block, find the expected height
  57555. * @returns expected height
  57556. */
  57557. computeExpectedHeight(): number;
  57558. dispose(): void;
  57559. }
  57560. }
  57561. declare module BABYLON.GUI {
  57562. /**
  57563. * Class used to create 2D images
  57564. */
  57565. export class Image extends Control {
  57566. name?: string | undefined;
  57567. private static _WorkingCanvas;
  57568. private _domImage;
  57569. private _imageWidth;
  57570. private _imageHeight;
  57571. private _loaded;
  57572. private _stretch;
  57573. private _source;
  57574. private _autoScale;
  57575. private _sourceLeft;
  57576. private _sourceTop;
  57577. private _sourceWidth;
  57578. private _sourceHeight;
  57579. private _cellWidth;
  57580. private _cellHeight;
  57581. private _cellId;
  57582. private _populateNinePatchSlicesFromImage;
  57583. private _sliceLeft;
  57584. private _sliceRight;
  57585. private _sliceTop;
  57586. private _sliceBottom;
  57587. private _detectPointerOnOpaqueOnly;
  57588. /**
  57589. * BABYLON.Observable notified when the content is loaded
  57590. */
  57591. onImageLoadedObservable: BABYLON.Observable<Image>;
  57592. /**
  57593. * Gets a boolean indicating that the content is loaded
  57594. */
  57595. readonly isLoaded: boolean;
  57596. /**
  57597. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  57598. */
  57599. populateNinePatchSlicesFromImage: boolean;
  57600. /**
  57601. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  57602. * Beware using this as this will comsume more memory as the image has to be stored twice
  57603. */
  57604. detectPointerOnOpaqueOnly: boolean;
  57605. /**
  57606. * Gets or sets the left value for slicing (9-patch)
  57607. */
  57608. sliceLeft: number;
  57609. /**
  57610. * Gets or sets the right value for slicing (9-patch)
  57611. */
  57612. sliceRight: number;
  57613. /**
  57614. * Gets or sets the top value for slicing (9-patch)
  57615. */
  57616. sliceTop: number;
  57617. /**
  57618. * Gets or sets the bottom value for slicing (9-patch)
  57619. */
  57620. sliceBottom: number;
  57621. /**
  57622. * Gets or sets the left coordinate in the source image
  57623. */
  57624. sourceLeft: number;
  57625. /**
  57626. * Gets or sets the top coordinate in the source image
  57627. */
  57628. sourceTop: number;
  57629. /**
  57630. * Gets or sets the width to capture in the source image
  57631. */
  57632. sourceWidth: number;
  57633. /**
  57634. * Gets or sets the height to capture in the source image
  57635. */
  57636. sourceHeight: number;
  57637. /**
  57638. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  57639. * @see http://doc.babylonjs.com/how_to/gui#image
  57640. */
  57641. autoScale: boolean;
  57642. /** Gets or sets the streching mode used by the image */
  57643. stretch: number;
  57644. /**
  57645. * Gets or sets the internal DOM image used to render the control
  57646. */
  57647. domImage: HTMLImageElement;
  57648. private _onImageLoaded;
  57649. private _extractNinePatchSliceDataFromImage;
  57650. /**
  57651. * Gets or sets image source url
  57652. */
  57653. source: BABYLON.Nullable<string>;
  57654. /**
  57655. * Gets or sets the cell width to use when animation sheet is enabled
  57656. * @see http://doc.babylonjs.com/how_to/gui#image
  57657. */
  57658. cellWidth: number;
  57659. /**
  57660. * Gets or sets the cell height to use when animation sheet is enabled
  57661. * @see http://doc.babylonjs.com/how_to/gui#image
  57662. */
  57663. cellHeight: number;
  57664. /**
  57665. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  57666. * @see http://doc.babylonjs.com/how_to/gui#image
  57667. */
  57668. cellId: number;
  57669. /**
  57670. * Creates a new Image
  57671. * @param name defines the control name
  57672. * @param url defines the image url
  57673. */
  57674. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  57675. /**
  57676. * Tests if a given coordinates belong to the current control
  57677. * @param x defines x coordinate to test
  57678. * @param y defines y coordinate to test
  57679. * @returns true if the coordinates are inside the control
  57680. */
  57681. contains(x: number, y: number): boolean;
  57682. protected _getTypeName(): string;
  57683. /** Force the control to synchronize with its content */
  57684. synchronizeSizeWithContent(): void;
  57685. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57686. private _prepareWorkingCanvasForOpaqueDetection;
  57687. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  57688. private _renderCornerPatch;
  57689. private _renderNinePatch;
  57690. dispose(): void;
  57691. /** STRETCH_NONE */
  57692. static readonly STRETCH_NONE: number;
  57693. /** STRETCH_FILL */
  57694. static readonly STRETCH_FILL: number;
  57695. /** STRETCH_UNIFORM */
  57696. static readonly STRETCH_UNIFORM: number;
  57697. /** STRETCH_EXTEND */
  57698. static readonly STRETCH_EXTEND: number;
  57699. /** NINE_PATCH */
  57700. static readonly STRETCH_NINE_PATCH: number;
  57701. }
  57702. }
  57703. declare module BABYLON.GUI {
  57704. /**
  57705. * Class used to create 2D buttons
  57706. */
  57707. export class Button extends Rectangle {
  57708. name?: string | undefined;
  57709. /**
  57710. * Function called to generate a pointer enter animation
  57711. */
  57712. pointerEnterAnimation: () => void;
  57713. /**
  57714. * Function called to generate a pointer out animation
  57715. */
  57716. pointerOutAnimation: () => void;
  57717. /**
  57718. * Function called to generate a pointer down animation
  57719. */
  57720. pointerDownAnimation: () => void;
  57721. /**
  57722. * Function called to generate a pointer up animation
  57723. */
  57724. pointerUpAnimation: () => void;
  57725. private _image;
  57726. /**
  57727. * Returns the image part of the button (if any)
  57728. */
  57729. readonly image: BABYLON.Nullable<Image>;
  57730. private _textBlock;
  57731. /**
  57732. * Returns the image part of the button (if any)
  57733. */
  57734. readonly textBlock: BABYLON.Nullable<TextBlock>;
  57735. /**
  57736. * Creates a new Button
  57737. * @param name defines the name of the button
  57738. */
  57739. constructor(name?: string | undefined);
  57740. protected _getTypeName(): string;
  57741. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57742. /** @hidden */ onPointerEnter(target: Control): boolean;
  57743. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57744. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57745. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57746. /**
  57747. * Creates a new button made with an image and a text
  57748. * @param name defines the name of the button
  57749. * @param text defines the text of the button
  57750. * @param imageUrl defines the url of the image
  57751. * @returns a new Button
  57752. */
  57753. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  57754. /**
  57755. * Creates a new button made with an image
  57756. * @param name defines the name of the button
  57757. * @param imageUrl defines the url of the image
  57758. * @returns a new Button
  57759. */
  57760. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  57761. /**
  57762. * Creates a new button made with a text
  57763. * @param name defines the name of the button
  57764. * @param text defines the text of the button
  57765. * @returns a new Button
  57766. */
  57767. static CreateSimpleButton(name: string, text: string): Button;
  57768. /**
  57769. * Creates a new button made with an image and a centered text
  57770. * @param name defines the name of the button
  57771. * @param text defines the text of the button
  57772. * @param imageUrl defines the url of the image
  57773. * @returns a new Button
  57774. */
  57775. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  57776. }
  57777. }
  57778. declare module BABYLON.GUI {
  57779. /**
  57780. * Class used to create a 2D stack panel container
  57781. */
  57782. export class StackPanel extends Container {
  57783. name?: string | undefined;
  57784. private _isVertical;
  57785. private _manualWidth;
  57786. private _manualHeight;
  57787. private _doNotTrackManualChanges;
  57788. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  57789. isVertical: boolean;
  57790. /**
  57791. * Gets or sets panel width.
  57792. * This value should not be set when in horizontal mode as it will be computed automatically
  57793. */
  57794. width: string | number;
  57795. /**
  57796. * Gets or sets panel height.
  57797. * This value should not be set when in vertical mode as it will be computed automatically
  57798. */
  57799. height: string | number;
  57800. /**
  57801. * Creates a new StackPanel
  57802. * @param name defines control name
  57803. */
  57804. constructor(name?: string | undefined);
  57805. protected _getTypeName(): string;
  57806. /** @hidden */
  57807. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57808. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57809. protected _postMeasure(): void;
  57810. }
  57811. }
  57812. declare module BABYLON.GUI {
  57813. /**
  57814. * Class used to represent a 2D checkbox
  57815. */
  57816. export class Checkbox extends Control {
  57817. name?: string | undefined;
  57818. private _isChecked;
  57819. private _background;
  57820. private _checkSizeRatio;
  57821. private _thickness;
  57822. /** Gets or sets border thickness */
  57823. thickness: number;
  57824. /**
  57825. * BABYLON.Observable raised when isChecked property changes
  57826. */
  57827. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  57828. /** Gets or sets a value indicating the ratio between overall size and check size */
  57829. checkSizeRatio: number;
  57830. /** Gets or sets background color */
  57831. background: string;
  57832. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  57833. isChecked: boolean;
  57834. /**
  57835. * Creates a new CheckBox
  57836. * @param name defines the control name
  57837. */
  57838. constructor(name?: string | undefined);
  57839. protected _getTypeName(): string;
  57840. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57841. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57842. /**
  57843. * Utility function to easily create a checkbox with a header
  57844. * @param title defines the label to use for the header
  57845. * @param onValueChanged defines the callback to call when value changes
  57846. * @returns a StackPanel containing the checkbox and a textBlock
  57847. */
  57848. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  57849. }
  57850. }
  57851. declare module BABYLON.GUI {
  57852. /**
  57853. * Class used to store key control properties
  57854. */
  57855. export class KeyPropertySet {
  57856. /** Width */
  57857. width?: string;
  57858. /** Height */
  57859. height?: string;
  57860. /** Left padding */
  57861. paddingLeft?: string;
  57862. /** Right padding */
  57863. paddingRight?: string;
  57864. /** Top padding */
  57865. paddingTop?: string;
  57866. /** Bottom padding */
  57867. paddingBottom?: string;
  57868. /** Foreground color */
  57869. color?: string;
  57870. /** Background color */
  57871. background?: string;
  57872. }
  57873. /**
  57874. * Class used to create virtual keyboard
  57875. */
  57876. export class VirtualKeyboard extends StackPanel {
  57877. /** BABYLON.Observable raised when a key is pressed */
  57878. onKeyPressObservable: BABYLON.Observable<string>;
  57879. /** Gets or sets default key button width */
  57880. defaultButtonWidth: string;
  57881. /** Gets or sets default key button height */
  57882. defaultButtonHeight: string;
  57883. /** Gets or sets default key button left padding */
  57884. defaultButtonPaddingLeft: string;
  57885. /** Gets or sets default key button right padding */
  57886. defaultButtonPaddingRight: string;
  57887. /** Gets or sets default key button top padding */
  57888. defaultButtonPaddingTop: string;
  57889. /** Gets or sets default key button bottom padding */
  57890. defaultButtonPaddingBottom: string;
  57891. /** Gets or sets default key button foreground color */
  57892. defaultButtonColor: string;
  57893. /** Gets or sets default key button background color */
  57894. defaultButtonBackground: string;
  57895. /** Gets or sets shift button foreground color */
  57896. shiftButtonColor: string;
  57897. /** Gets or sets shift button thickness*/
  57898. selectedShiftThickness: number;
  57899. /** Gets shift key state */
  57900. shiftState: number;
  57901. protected _getTypeName(): string;
  57902. private _createKey;
  57903. /**
  57904. * Adds a new row of keys
  57905. * @param keys defines the list of keys to add
  57906. * @param propertySets defines the associated property sets
  57907. */
  57908. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  57909. /**
  57910. * Set the shift key to a specific state
  57911. * @param shiftState defines the new shift state
  57912. */
  57913. applyShiftState(shiftState: number): void;
  57914. private _currentlyConnectedInputText;
  57915. private _connectedInputTexts;
  57916. private _onKeyPressObserver;
  57917. /** Gets the input text control currently attached to the keyboard */
  57918. readonly connectedInputText: BABYLON.Nullable<InputText>;
  57919. /**
  57920. * Connects the keyboard with an input text control
  57921. *
  57922. * @param input defines the target control
  57923. */
  57924. connect(input: InputText): void;
  57925. /**
  57926. * Disconnects the keyboard from connected InputText controls
  57927. *
  57928. * @param input optionally defines a target control, otherwise all are disconnected
  57929. */
  57930. disconnect(input?: InputText): void;
  57931. private _removeConnectedInputObservables;
  57932. /**
  57933. * Release all resources
  57934. */
  57935. dispose(): void;
  57936. /**
  57937. * Creates a new keyboard using a default layout
  57938. *
  57939. * @param name defines control name
  57940. * @returns a new VirtualKeyboard
  57941. */
  57942. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  57943. }
  57944. }
  57945. declare module BABYLON.GUI {
  57946. /**
  57947. * Class used to create input text control
  57948. */
  57949. export class InputText extends Control implements IFocusableControl {
  57950. name?: string | undefined;
  57951. private _text;
  57952. private _placeholderText;
  57953. private _background;
  57954. private _focusedBackground;
  57955. private _focusedColor;
  57956. private _placeholderColor;
  57957. private _thickness;
  57958. private _margin;
  57959. private _autoStretchWidth;
  57960. private _maxWidth;
  57961. private _isFocused;
  57962. private _blinkTimeout;
  57963. private _blinkIsEven;
  57964. private _cursorOffset;
  57965. private _scrollLeft;
  57966. private _textWidth;
  57967. private _clickedCoordinate;
  57968. private _deadKey;
  57969. private _addKey;
  57970. private _currentKey;
  57971. private _isTextHighlightOn;
  57972. private _textHighlightColor;
  57973. private _highligherOpacity;
  57974. private _highlightedText;
  57975. private _startHighlightIndex;
  57976. private _endHighlightIndex;
  57977. private _cursorIndex;
  57978. private _onFocusSelectAll;
  57979. private _isPointerDown;
  57980. private _onClipboardObserver;
  57981. private _onPointerDblTapObserver;
  57982. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  57983. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  57984. promptMessage: string;
  57985. /** BABYLON.Observable raised when the text changes */
  57986. onTextChangedObservable: BABYLON.Observable<InputText>;
  57987. /** BABYLON.Observable raised just before an entered character is to be added */
  57988. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  57989. /** BABYLON.Observable raised when the control gets the focus */
  57990. onFocusObservable: BABYLON.Observable<InputText>;
  57991. /** BABYLON.Observable raised when the control loses the focus */
  57992. onBlurObservable: BABYLON.Observable<InputText>;
  57993. /**Observable raised when the text is highlighted */
  57994. onTextHighlightObservable: BABYLON.Observable<InputText>;
  57995. /**Observable raised when copy event is triggered */
  57996. onTextCopyObservable: BABYLON.Observable<InputText>;
  57997. /** BABYLON.Observable raised when cut event is triggered */
  57998. onTextCutObservable: BABYLON.Observable<InputText>;
  57999. /** BABYLON.Observable raised when paste event is triggered */
  58000. onTextPasteObservable: BABYLON.Observable<InputText>;
  58001. /** BABYLON.Observable raised when a key event was processed */
  58002. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  58003. /** Gets or sets the maximum width allowed by the control */
  58004. maxWidth: string | number;
  58005. /** Gets the maximum width allowed by the control in pixels */
  58006. readonly maxWidthInPixels: number;
  58007. /** Gets or sets the text highlighter transparency; default: 0.4 */
  58008. highligherOpacity: number;
  58009. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  58010. onFocusSelectAll: boolean;
  58011. /** Gets or sets the text hightlight color */
  58012. textHighlightColor: string;
  58013. /** Gets or sets control margin */
  58014. margin: string;
  58015. /** Gets control margin in pixels */
  58016. readonly marginInPixels: number;
  58017. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  58018. autoStretchWidth: boolean;
  58019. /** Gets or sets border thickness */
  58020. thickness: number;
  58021. /** Gets or sets the background color when focused */
  58022. focusedBackground: string;
  58023. /** Gets or sets the background color when focused */
  58024. focusedColor: string;
  58025. /** Gets or sets the background color */
  58026. background: string;
  58027. /** Gets or sets the placeholder color */
  58028. placeholderColor: string;
  58029. /** Gets or sets the text displayed when the control is empty */
  58030. placeholderText: string;
  58031. /** Gets or sets the dead key flag */
  58032. deadKey: boolean;
  58033. /** Gets or sets the highlight text */
  58034. highlightedText: string;
  58035. /** Gets or sets if the current key should be added */
  58036. addKey: boolean;
  58037. /** Gets or sets the value of the current key being entered */
  58038. currentKey: string;
  58039. /** Gets or sets the text displayed in the control */
  58040. text: string;
  58041. /** Gets or sets control width */
  58042. width: string | number;
  58043. /**
  58044. * Creates a new InputText
  58045. * @param name defines the control name
  58046. * @param text defines the text of the control
  58047. */
  58048. constructor(name?: string | undefined, text?: string);
  58049. /** @hidden */
  58050. onBlur(): void;
  58051. /** @hidden */
  58052. onFocus(): void;
  58053. protected _getTypeName(): string;
  58054. /**
  58055. * Function called to get the list of controls that should not steal the focus from this control
  58056. * @returns an array of controls
  58057. */
  58058. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  58059. /** @hidden */
  58060. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  58061. /** @hidden */
  58062. private _updateValueFromCursorIndex;
  58063. /** @hidden */
  58064. private _processDblClick;
  58065. /** @hidden */
  58066. private _selectAllText;
  58067. /**
  58068. * Handles the keyboard event
  58069. * @param evt Defines the KeyboardEvent
  58070. */
  58071. processKeyboard(evt: KeyboardEvent): void;
  58072. /** @hidden */
  58073. private _onCopyText;
  58074. /** @hidden */
  58075. private _onCutText;
  58076. /** @hidden */
  58077. private _onPasteText; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58078. protected _beforeRenderText(text: string): string;
  58079. dispose(): void;
  58080. }
  58081. }
  58082. declare module BABYLON.GUI {
  58083. /**
  58084. * Class used to create a 2D grid container
  58085. */
  58086. export class Grid extends Container {
  58087. name?: string | undefined;
  58088. private _rowDefinitions;
  58089. private _columnDefinitions;
  58090. private _cells;
  58091. private _childControls;
  58092. /**
  58093. * Gets the number of columns
  58094. */
  58095. readonly columnCount: number;
  58096. /**
  58097. * Gets the number of rows
  58098. */
  58099. readonly rowCount: number;
  58100. /** Gets the list of children */
  58101. readonly children: Control[];
  58102. /**
  58103. * Gets the definition of a specific row
  58104. * @param index defines the index of the row
  58105. * @returns the row definition
  58106. */
  58107. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  58108. /**
  58109. * Gets the definition of a specific column
  58110. * @param index defines the index of the column
  58111. * @returns the column definition
  58112. */
  58113. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  58114. /**
  58115. * Adds a new row to the grid
  58116. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  58117. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  58118. * @returns the current grid
  58119. */
  58120. addRowDefinition(height: number, isPixel?: boolean): Grid;
  58121. /**
  58122. * Adds a new column to the grid
  58123. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  58124. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  58125. * @returns the current grid
  58126. */
  58127. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  58128. /**
  58129. * Update a row definition
  58130. * @param index defines the index of the row to update
  58131. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  58132. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  58133. * @returns the current grid
  58134. */
  58135. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  58136. /**
  58137. * Update a column definition
  58138. * @param index defines the index of the column to update
  58139. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  58140. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  58141. * @returns the current grid
  58142. */
  58143. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  58144. /**
  58145. * Gets the list of children stored in a specific cell
  58146. * @param row defines the row to check
  58147. * @param column defines the column to check
  58148. * @returns the list of controls
  58149. */
  58150. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  58151. /**
  58152. * Gets a string representing the child cell info (row x column)
  58153. * @param child defines the control to get info from
  58154. * @returns a string containing the child cell info (row x column)
  58155. */
  58156. getChildCellInfo(child: Control): string;
  58157. private _removeCell;
  58158. private _offsetCell;
  58159. /**
  58160. * Remove a column definition at specified index
  58161. * @param index defines the index of the column to remove
  58162. * @returns the current grid
  58163. */
  58164. removeColumnDefinition(index: number): Grid;
  58165. /**
  58166. * Remove a row definition at specified index
  58167. * @param index defines the index of the row to remove
  58168. * @returns the current grid
  58169. */
  58170. removeRowDefinition(index: number): Grid;
  58171. /**
  58172. * Adds a new control to the current grid
  58173. * @param control defines the control to add
  58174. * @param row defines the row where to add the control (0 by default)
  58175. * @param column defines the column where to add the control (0 by default)
  58176. * @returns the current grid
  58177. */
  58178. addControl(control: Control, row?: number, column?: number): Grid;
  58179. /**
  58180. * Removes a control from the current container
  58181. * @param control defines the control to remove
  58182. * @returns the current container
  58183. */
  58184. removeControl(control: Control): Container;
  58185. /**
  58186. * Creates a new Grid
  58187. * @param name defines control name
  58188. */
  58189. constructor(name?: string | undefined);
  58190. protected _getTypeName(): string;
  58191. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  58192. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58193. /** Releases associated resources */
  58194. dispose(): void;
  58195. }
  58196. }
  58197. declare module BABYLON.GUI {
  58198. /** Class used to create color pickers */
  58199. export class ColorPicker extends Control {
  58200. name?: string | undefined;
  58201. private static _Epsilon;
  58202. private _colorWheelCanvas;
  58203. private _value;
  58204. private _tmpColor;
  58205. private _pointerStartedOnSquare;
  58206. private _pointerStartedOnWheel;
  58207. private _squareLeft;
  58208. private _squareTop;
  58209. private _squareSize;
  58210. private _h;
  58211. private _s;
  58212. private _v;
  58213. /**
  58214. * BABYLON.Observable raised when the value changes
  58215. */
  58216. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  58217. /** Gets or sets the color of the color picker */
  58218. value: BABYLON.Color3;
  58219. /**
  58220. * Gets or sets control width
  58221. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58222. */
  58223. width: string | number;
  58224. /**
  58225. * Gets or sets control height
  58226. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58227. */
  58228. /** Gets or sets control height */
  58229. height: string | number;
  58230. /** Gets or sets control size */
  58231. size: string | number;
  58232. /**
  58233. * Creates a new ColorPicker
  58234. * @param name defines the control name
  58235. */
  58236. constructor(name?: string | undefined);
  58237. protected _getTypeName(): string;
  58238. /** @hidden */
  58239. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58240. private _updateSquareProps;
  58241. private _drawGradientSquare;
  58242. private _drawCircle;
  58243. private _createColorWheelCanvas;
  58244. private _RGBtoHSV;
  58245. private _HSVtoRGB;
  58246. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  58247. private _pointerIsDown;
  58248. private _updateValueFromPointer;
  58249. private _isPointOnSquare;
  58250. private _isPointOnWheel; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58251. /**
  58252. * This function expands the color picker by creating a color picker dialog with manual
  58253. * color value input and the ability to save colors into an array to be used later in
  58254. * subsequent launches of the dialogue.
  58255. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  58256. * @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.
  58257. * @returns picked color as a hex string and the saved colors array as hex strings.
  58258. */
  58259. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  58260. pickerWidth?: string;
  58261. pickerHeight?: string;
  58262. headerHeight?: string;
  58263. lastColor?: string;
  58264. swatchLimit?: number;
  58265. numSwatchesPerLine?: number;
  58266. savedColors?: Array<string>;
  58267. }): Promise<{
  58268. savedColors?: string[];
  58269. pickedColor: string;
  58270. }>;
  58271. }
  58272. }
  58273. declare module BABYLON.GUI {
  58274. /** Class used to create 2D ellipse containers */
  58275. export class Ellipse extends Container {
  58276. name?: string | undefined;
  58277. private _thickness;
  58278. /** Gets or sets border thickness */
  58279. thickness: number;
  58280. /**
  58281. * Creates a new Ellipse
  58282. * @param name defines the control name
  58283. */
  58284. constructor(name?: string | undefined);
  58285. protected _getTypeName(): string;
  58286. protected _localDraw(context: CanvasRenderingContext2D): void;
  58287. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58288. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  58289. }
  58290. }
  58291. declare module BABYLON.GUI {
  58292. /**
  58293. * Class used to create a password control
  58294. */
  58295. export class InputPassword extends InputText {
  58296. protected _beforeRenderText(text: string): string;
  58297. }
  58298. }
  58299. declare module BABYLON.GUI {
  58300. /** Class used to render 2D lines */
  58301. export class Line extends Control {
  58302. name?: string | undefined;
  58303. private _lineWidth;
  58304. private _x1;
  58305. private _y1;
  58306. private _x2;
  58307. private _y2;
  58308. private _dash;
  58309. private _connectedControl;
  58310. private _connectedControlDirtyObserver;
  58311. /** Gets or sets the dash pattern */
  58312. dash: Array<number>;
  58313. /** Gets or sets the control connected with the line end */
  58314. connectedControl: Control;
  58315. /** Gets or sets start coordinates on X axis */
  58316. x1: string | number;
  58317. /** Gets or sets start coordinates on Y axis */
  58318. y1: string | number;
  58319. /** Gets or sets end coordinates on X axis */
  58320. x2: string | number;
  58321. /** Gets or sets end coordinates on Y axis */
  58322. y2: string | number;
  58323. /** Gets or sets line width */
  58324. lineWidth: number;
  58325. /** Gets or sets horizontal alignment */
  58326. horizontalAlignment: number;
  58327. /** Gets or sets vertical alignment */
  58328. verticalAlignment: number;
  58329. private readonly _effectiveX2;
  58330. private readonly _effectiveY2;
  58331. /**
  58332. * Creates a new Line
  58333. * @param name defines the control name
  58334. */
  58335. constructor(name?: string | undefined);
  58336. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  58337. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58338. /**
  58339. * Move one end of the line given 3D cartesian coordinates.
  58340. * @param position Targeted world position
  58341. * @param scene BABYLON.Scene
  58342. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58343. */
  58344. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  58345. /**
  58346. * Move one end of the line to a position in screen absolute space.
  58347. * @param projectedPosition Position in screen absolute space (X, Y)
  58348. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58349. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  58350. }
  58351. }
  58352. declare module BABYLON.GUI {
  58353. /**
  58354. * Class used to store a point for a MultiLine object.
  58355. * The point can be pure 2D coordinates, a mesh or a control
  58356. */
  58357. export class MultiLinePoint {
  58358. private _multiLine;
  58359. private _x;
  58360. private _y;
  58361. private _control;
  58362. private _mesh;
  58363. private _controlObserver;
  58364. private _meshObserver;
  58365. /** @hidden */ point: BABYLON.Vector2;
  58366. /**
  58367. * Creates a new MultiLinePoint
  58368. * @param multiLine defines the source MultiLine object
  58369. */
  58370. constructor(multiLine: MultiLine);
  58371. /** Gets or sets x coordinate */
  58372. x: string | number;
  58373. /** Gets or sets y coordinate */
  58374. y: string | number;
  58375. /** Gets or sets the control associated with this point */
  58376. control: BABYLON.Nullable<Control>;
  58377. /** Gets or sets the mesh associated with this point */
  58378. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58379. /** Resets links */
  58380. resetLinks(): void;
  58381. /**
  58382. * Gets a translation vector
  58383. * @returns the translation vector
  58384. */
  58385. translate(): BABYLON.Vector2;
  58386. private _translatePoint;
  58387. /** Release associated resources */
  58388. dispose(): void;
  58389. }
  58390. }
  58391. declare module BABYLON.GUI {
  58392. /**
  58393. * Class used to create multi line control
  58394. */
  58395. export class MultiLine extends Control {
  58396. name?: string | undefined;
  58397. private _lineWidth;
  58398. private _dash;
  58399. private _points;
  58400. private _minX;
  58401. private _minY;
  58402. private _maxX;
  58403. private _maxY;
  58404. /**
  58405. * Creates a new MultiLine
  58406. * @param name defines the control name
  58407. */
  58408. constructor(name?: string | undefined);
  58409. /** Gets or sets dash pattern */
  58410. dash: Array<number>;
  58411. /**
  58412. * Gets point stored at specified index
  58413. * @param index defines the index to look for
  58414. * @returns the requested point if found
  58415. */
  58416. getAt(index: number): MultiLinePoint;
  58417. /** Function called when a point is updated */
  58418. onPointUpdate: () => void;
  58419. /**
  58420. * Adds new points to the point collection
  58421. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  58422. * @returns the list of created MultiLinePoint
  58423. */
  58424. add(...items: (AbstractMesh | Control | {
  58425. x: string | number;
  58426. y: string | number;
  58427. })[]): MultiLinePoint[];
  58428. /**
  58429. * Adds a new point to the point collection
  58430. * @param item defines the item (mesh, control or 2d coordiantes) to add
  58431. * @returns the created MultiLinePoint
  58432. */
  58433. push(item?: (AbstractMesh | Control | {
  58434. x: string | number;
  58435. y: string | number;
  58436. })): MultiLinePoint;
  58437. /**
  58438. * Remove a specific value or point from the active point collection
  58439. * @param value defines the value or point to remove
  58440. */
  58441. remove(value: number | MultiLinePoint): void;
  58442. /**
  58443. * Resets this object to initial state (no point)
  58444. */
  58445. reset(): void;
  58446. /**
  58447. * Resets all links
  58448. */
  58449. resetLinks(): void;
  58450. /** Gets or sets line width */
  58451. lineWidth: number;
  58452. horizontalAlignment: number;
  58453. verticalAlignment: number;
  58454. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58455. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  58456. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58457. dispose(): void;
  58458. }
  58459. }
  58460. declare module BABYLON.GUI {
  58461. /**
  58462. * Class used to create radio button controls
  58463. */
  58464. export class RadioButton extends Control {
  58465. name?: string | undefined;
  58466. private _isChecked;
  58467. private _background;
  58468. private _checkSizeRatio;
  58469. private _thickness;
  58470. /** Gets or sets border thickness */
  58471. thickness: number;
  58472. /** Gets or sets group name */
  58473. group: string;
  58474. /** BABYLON.Observable raised when isChecked is changed */
  58475. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  58476. /** Gets or sets a value indicating the ratio between overall size and check size */
  58477. checkSizeRatio: number;
  58478. /** Gets or sets background color */
  58479. background: string;
  58480. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  58481. isChecked: boolean;
  58482. /**
  58483. * Creates a new RadioButton
  58484. * @param name defines the control name
  58485. */
  58486. constructor(name?: string | undefined);
  58487. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58488. /**
  58489. * Utility function to easily create a radio button with a header
  58490. * @param title defines the label to use for the header
  58491. * @param group defines the group to use for the radio button
  58492. * @param isChecked defines the initial state of the radio button
  58493. * @param onValueChanged defines the callback to call when value changes
  58494. * @returns a StackPanel containing the radio button and a textBlock
  58495. */
  58496. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  58497. }
  58498. }
  58499. declare module BABYLON.GUI {
  58500. /**
  58501. * Class used to create slider controls
  58502. */
  58503. export class BaseSlider extends Control {
  58504. name?: string | undefined;
  58505. protected _thumbWidth: ValueAndUnit;
  58506. private _minimum;
  58507. private _maximum;
  58508. private _value;
  58509. private _isVertical;
  58510. protected _barOffset: ValueAndUnit;
  58511. private _isThumbClamped;
  58512. protected _displayThumb: boolean;
  58513. private _step;
  58514. protected _effectiveBarOffset: number;
  58515. protected _renderLeft: number;
  58516. protected _renderTop: number;
  58517. protected _renderWidth: number;
  58518. protected _renderHeight: number;
  58519. protected _backgroundBoxLength: number;
  58520. protected _backgroundBoxThickness: number;
  58521. protected _effectiveThumbThickness: number;
  58522. /** BABYLON.Observable raised when the sldier value changes */
  58523. onValueChangedObservable: BABYLON.Observable<number>;
  58524. /** Gets or sets a boolean indicating if the thumb must be rendered */
  58525. displayThumb: boolean;
  58526. /** Gets or sets a step to apply to values (0 by default) */
  58527. step: number;
  58528. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  58529. barOffset: string | number;
  58530. /** Gets main bar offset in pixels*/
  58531. readonly barOffsetInPixels: number;
  58532. /** Gets or sets thumb width */
  58533. thumbWidth: string | number;
  58534. /** Gets thumb width in pixels */
  58535. readonly thumbWidthInPixels: number;
  58536. /** Gets or sets minimum value */
  58537. minimum: number;
  58538. /** Gets or sets maximum value */
  58539. maximum: number;
  58540. /** Gets or sets current value */
  58541. value: number;
  58542. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  58543. isVertical: boolean;
  58544. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  58545. isThumbClamped: boolean;
  58546. /**
  58547. * Creates a new BaseSlider
  58548. * @param name defines the control name
  58549. */
  58550. constructor(name?: string | undefined);
  58551. protected _getTypeName(): string;
  58552. protected _getThumbPosition(): number;
  58553. protected _getThumbThickness(type: string): number;
  58554. protected _prepareRenderingData(type: string): void;
  58555. private _pointerIsDown;
  58556. /** @hidden */
  58557. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58558. }
  58559. }
  58560. declare module BABYLON.GUI {
  58561. /**
  58562. * Class used to create slider controls
  58563. */
  58564. export class Slider extends BaseSlider {
  58565. name?: string | undefined;
  58566. private _background;
  58567. private _borderColor;
  58568. private _isThumbCircle;
  58569. protected _displayValueBar: boolean;
  58570. /** Gets or sets a boolean indicating if the value bar must be rendered */
  58571. displayValueBar: boolean;
  58572. /** Gets or sets border color */
  58573. borderColor: string;
  58574. /** Gets or sets background color */
  58575. background: string;
  58576. /** Gets or sets a boolean indicating if the thumb should be round or square */
  58577. isThumbCircle: boolean;
  58578. /**
  58579. * Creates a new Slider
  58580. * @param name defines the control name
  58581. */
  58582. constructor(name?: string | undefined);
  58583. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58584. }
  58585. }
  58586. declare module BABYLON.GUI {
  58587. /** Class used to create a RadioGroup
  58588. * which contains groups of radio buttons
  58589. */
  58590. export class SelectorGroup {
  58591. /** name of SelectorGroup */
  58592. name: string;
  58593. private _groupPanel;
  58594. private _selectors;
  58595. private _groupHeader;
  58596. /**
  58597. * Creates a new SelectorGroup
  58598. * @param name of group, used as a group heading
  58599. */
  58600. constructor(
  58601. /** name of SelectorGroup */
  58602. name: string);
  58603. /** Gets the groupPanel of the SelectorGroup */
  58604. readonly groupPanel: StackPanel;
  58605. /** Gets the selectors array */
  58606. readonly selectors: StackPanel[];
  58607. /** Gets and sets the group header */
  58608. header: string;
  58609. /** @hidden */
  58610. private _addGroupHeader;
  58611. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  58612. /** Removes the selector at the given position
  58613. * @param selectorNb the position of the selector within the group
  58614. */
  58615. removeSelector(selectorNb: number): void;
  58616. }
  58617. /** Class used to create a CheckboxGroup
  58618. * which contains groups of checkbox buttons
  58619. */
  58620. export class CheckboxGroup extends SelectorGroup {
  58621. /** Adds a checkbox as a control
  58622. * @param text is the label for the selector
  58623. * @param func is the function called when the Selector is checked
  58624. * @param checked is true when Selector is checked
  58625. */
  58626. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  58627. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58628. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58629. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58630. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58631. }
  58632. /** Class used to create a RadioGroup
  58633. * which contains groups of radio buttons
  58634. */
  58635. export class RadioGroup extends SelectorGroup {
  58636. private _selectNb;
  58637. /** Adds a radio button as a control
  58638. * @param label is the label for the selector
  58639. * @param func is the function called when the Selector is checked
  58640. * @param checked is true when Selector is checked
  58641. */
  58642. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  58643. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58644. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58645. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58646. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58647. }
  58648. /** Class used to create a SliderGroup
  58649. * which contains groups of slider buttons
  58650. */
  58651. export class SliderGroup extends SelectorGroup {
  58652. /**
  58653. * Adds a slider to the SelectorGroup
  58654. * @param label is the label for the SliderBar
  58655. * @param func is the function called when the Slider moves
  58656. * @param unit is a string describing the units used, eg degrees or metres
  58657. * @param min is the minimum value for the Slider
  58658. * @param max is the maximum value for the Slider
  58659. * @param value is the start value for the Slider between min and max
  58660. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  58661. */
  58662. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  58663. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58664. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58665. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58666. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58667. }
  58668. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  58669. * @see http://doc.babylonjs.com/how_to/selector
  58670. */
  58671. export class SelectionPanel extends Rectangle {
  58672. /** name of SelectionPanel */
  58673. name: string;
  58674. /** an array of SelectionGroups */
  58675. groups: SelectorGroup[];
  58676. private _panel;
  58677. private _buttonColor;
  58678. private _buttonBackground;
  58679. private _headerColor;
  58680. private _barColor;
  58681. private _barHeight;
  58682. private _spacerHeight;
  58683. private _labelColor;
  58684. private _groups;
  58685. private _bars;
  58686. /**
  58687. * Creates a new SelectionPanel
  58688. * @param name of SelectionPanel
  58689. * @param groups is an array of SelectionGroups
  58690. */
  58691. constructor(
  58692. /** name of SelectionPanel */
  58693. name: string,
  58694. /** an array of SelectionGroups */
  58695. groups?: SelectorGroup[]);
  58696. protected _getTypeName(): string;
  58697. /** Gets or sets the headerColor */
  58698. headerColor: string;
  58699. private _setHeaderColor;
  58700. /** Gets or sets the button color */
  58701. buttonColor: string;
  58702. private _setbuttonColor;
  58703. /** Gets or sets the label color */
  58704. labelColor: string;
  58705. private _setLabelColor;
  58706. /** Gets or sets the button background */
  58707. buttonBackground: string;
  58708. private _setButtonBackground;
  58709. /** Gets or sets the color of separator bar */
  58710. barColor: string;
  58711. private _setBarColor;
  58712. /** Gets or sets the height of separator bar */
  58713. barHeight: string;
  58714. private _setBarHeight;
  58715. /** Gets or sets the height of spacers*/
  58716. spacerHeight: string;
  58717. private _setSpacerHeight;
  58718. /** Adds a bar between groups */
  58719. private _addSpacer;
  58720. /** Add a group to the selection panel
  58721. * @param group is the selector group to add
  58722. */
  58723. addGroup(group: SelectorGroup): void;
  58724. /** Remove the group from the given position
  58725. * @param groupNb is the position of the group in the list
  58726. */
  58727. removeGroup(groupNb: number): void;
  58728. /** Change a group header label
  58729. * @param label is the new group header label
  58730. * @param groupNb is the number of the group to relabel
  58731. * */
  58732. setHeaderName(label: string, groupNb: number): void;
  58733. /** Change selector label to the one given
  58734. * @param label is the new selector label
  58735. * @param groupNb is the number of the groupcontaining the selector
  58736. * @param selectorNb is the number of the selector within a group to relabel
  58737. * */
  58738. relabel(label: string, groupNb: number, selectorNb: number): void;
  58739. /** For a given group position remove the selector at the given position
  58740. * @param groupNb is the number of the group to remove the selector from
  58741. * @param selectorNb is the number of the selector within the group
  58742. */
  58743. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  58744. /** For a given group position of correct type add a checkbox button
  58745. * @param groupNb is the number of the group to remove the selector from
  58746. * @param label is the label for the selector
  58747. * @param func is the function called when the Selector is checked
  58748. * @param checked is true when Selector is checked
  58749. */
  58750. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58751. /** For a given group position of correct type add a radio button
  58752. * @param groupNb is the number of the group to remove the selector from
  58753. * @param label is the label for the selector
  58754. * @param func is the function called when the Selector is checked
  58755. * @param checked is true when Selector is checked
  58756. */
  58757. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58758. /**
  58759. * For a given slider group add a slider
  58760. * @param groupNb is the number of the group to add the slider to
  58761. * @param label is the label for the Slider
  58762. * @param func is the function called when the Slider moves
  58763. * @param unit is a string describing the units used, eg degrees or metres
  58764. * @param min is the minimum value for the Slider
  58765. * @param max is the maximum value for the Slider
  58766. * @param value is the start value for the Slider between min and max
  58767. * @param onVal is the function used to format the value displayed, eg radians to degrees
  58768. */
  58769. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  58770. }
  58771. }
  58772. declare module BABYLON.GUI {
  58773. /**
  58774. * Class used to hold a the container for ScrollViewer
  58775. * @hidden
  58776. */
  58777. export class _ScrollViewerWindow extends Container {
  58778. parentClientWidth: number;
  58779. parentClientHeight: number;
  58780. /**
  58781. * Creates a new ScrollViewerWindow
  58782. * @param name of ScrollViewerWindow
  58783. */
  58784. constructor(name?: string);
  58785. protected _getTypeName(): string;
  58786. /** @hidden */
  58787. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58788. protected _postMeasure(): void;
  58789. }
  58790. }
  58791. declare module BABYLON.GUI {
  58792. /**
  58793. * Class used to create slider controls
  58794. */
  58795. export class ScrollBar extends BaseSlider {
  58796. name?: string | undefined;
  58797. private _background;
  58798. private _borderColor;
  58799. private _thumbMeasure;
  58800. /** Gets or sets border color */
  58801. borderColor: string;
  58802. /** Gets or sets background color */
  58803. background: string;
  58804. /**
  58805. * Creates a new Slider
  58806. * @param name defines the control name
  58807. */
  58808. constructor(name?: string | undefined);
  58809. protected _getTypeName(): string;
  58810. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  58811. private _first;
  58812. private _originX;
  58813. private _originY;
  58814. /** @hidden */
  58815. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58816. }
  58817. }
  58818. declare module BABYLON.GUI {
  58819. /**
  58820. * Class used to hold a viewer window and sliders in a grid
  58821. */
  58822. export class ScrollViewer extends Rectangle {
  58823. private _grid;
  58824. private _horizontalBarSpace;
  58825. private _verticalBarSpace;
  58826. private _dragSpace;
  58827. private _horizontalBar;
  58828. private _verticalBar;
  58829. private _barColor;
  58830. private _barBackground;
  58831. private _barSize;
  58832. private _endLeft;
  58833. private _endTop;
  58834. private _window;
  58835. private _pointerIsOver;
  58836. private _wheelPrecision;
  58837. private _onPointerObserver;
  58838. private _clientWidth;
  58839. private _clientHeight;
  58840. /**
  58841. * Gets the horizontal scrollbar
  58842. */
  58843. readonly horizontalBar: ScrollBar;
  58844. /**
  58845. * Gets the vertical scrollbar
  58846. */
  58847. readonly verticalBar: ScrollBar;
  58848. /**
  58849. * Adds a new control to the current container
  58850. * @param control defines the control to add
  58851. * @returns the current container
  58852. */
  58853. addControl(control: BABYLON.Nullable<Control>): Container;
  58854. /**
  58855. * Removes a control from the current container
  58856. * @param control defines the control to remove
  58857. * @returns the current container
  58858. */
  58859. removeControl(control: Control): Container;
  58860. /** Gets the list of children */
  58861. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  58862. /**
  58863. * Creates a new ScrollViewer
  58864. * @param name of ScrollViewer
  58865. */
  58866. constructor(name?: string);
  58867. /** Reset the scroll viewer window to initial size */
  58868. resetWindow(): void;
  58869. protected _getTypeName(): string;
  58870. private _buildClientSizes;
  58871. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58872. protected _postMeasure(): void;
  58873. /**
  58874. * Gets or sets the mouse wheel precision
  58875. * from 0 to 1 with a default value of 0.05
  58876. * */
  58877. wheelPrecision: number;
  58878. /** Gets or sets the bar color */
  58879. barColor: string;
  58880. /** Gets or sets the size of the bar */
  58881. barSize: number;
  58882. /** Gets or sets the bar background */
  58883. barBackground: string;
  58884. /** @hidden */
  58885. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  58886. /** @hidden */
  58887. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58888. /** Releases associated resources */
  58889. dispose(): void;
  58890. }
  58891. }
  58892. declare module BABYLON.GUI {
  58893. /** Class used to render a grid */
  58894. export class DisplayGrid extends Control {
  58895. name?: string | undefined;
  58896. private _cellWidth;
  58897. private _cellHeight;
  58898. private _minorLineTickness;
  58899. private _minorLineColor;
  58900. private _majorLineTickness;
  58901. private _majorLineColor;
  58902. private _majorLineFrequency;
  58903. private _background;
  58904. private _displayMajorLines;
  58905. private _displayMinorLines;
  58906. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  58907. displayMinorLines: boolean;
  58908. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  58909. displayMajorLines: boolean;
  58910. /** Gets or sets background color (Black by default) */
  58911. background: string;
  58912. /** Gets or sets the width of each cell (20 by default) */
  58913. cellWidth: number;
  58914. /** Gets or sets the height of each cell (20 by default) */
  58915. cellHeight: number;
  58916. /** Gets or sets the tickness of minor lines (1 by default) */
  58917. minorLineTickness: number;
  58918. /** Gets or sets the color of minor lines (DarkGray by default) */
  58919. minorLineColor: string;
  58920. /** Gets or sets the tickness of major lines (2 by default) */
  58921. majorLineTickness: number;
  58922. /** Gets or sets the color of major lines (White by default) */
  58923. majorLineColor: string;
  58924. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  58925. majorLineFrequency: number;
  58926. /**
  58927. * Creates a new GridDisplayRectangle
  58928. * @param name defines the control name
  58929. */
  58930. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  58931. protected _getTypeName(): string;
  58932. }
  58933. }
  58934. declare module BABYLON.GUI {
  58935. /**
  58936. * Class used to create slider controls based on images
  58937. */
  58938. export class ImageBasedSlider extends BaseSlider {
  58939. name?: string | undefined;
  58940. private _backgroundImage;
  58941. private _thumbImage;
  58942. private _valueBarImage;
  58943. private _tempMeasure;
  58944. displayThumb: boolean;
  58945. /**
  58946. * Gets or sets the image used to render the background
  58947. */
  58948. backgroundImage: Image;
  58949. /**
  58950. * Gets or sets the image used to render the value bar
  58951. */
  58952. valueBarImage: Image;
  58953. /**
  58954. * Gets or sets the image used to render the thumb
  58955. */
  58956. thumbImage: Image;
  58957. /**
  58958. * Creates a new ImageBasedSlider
  58959. * @param name defines the control name
  58960. */
  58961. constructor(name?: string | undefined);
  58962. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58963. }
  58964. }
  58965. declare module BABYLON.GUI {
  58966. /**
  58967. * Forcing an export so that this code will execute
  58968. * @hidden
  58969. */
  58970. const name = "Statics";
  58971. }
  58972. declare module BABYLON.GUI {
  58973. /**
  58974. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  58975. */
  58976. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  58977. /**
  58978. * Define the instrumented AdvancedDynamicTexture.
  58979. */
  58980. texture: AdvancedDynamicTexture;
  58981. private _captureRenderTime;
  58982. private _renderTime;
  58983. private _captureLayoutTime;
  58984. private _layoutTime;
  58985. private _onBeginRenderObserver;
  58986. private _onEndRenderObserver;
  58987. private _onBeginLayoutObserver;
  58988. private _onEndLayoutObserver;
  58989. /**
  58990. * Gets the perf counter used to capture render time
  58991. */
  58992. readonly renderTimeCounter: BABYLON.PerfCounter;
  58993. /**
  58994. * Gets the perf counter used to capture layout time
  58995. */
  58996. readonly layoutTimeCounter: BABYLON.PerfCounter;
  58997. /**
  58998. * Enable or disable the render time capture
  58999. */
  59000. captureRenderTime: boolean;
  59001. /**
  59002. * Enable or disable the layout time capture
  59003. */
  59004. captureLayoutTime: boolean;
  59005. /**
  59006. * Instantiates a new advanced dynamic texture instrumentation.
  59007. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  59008. * @param texture Defines the AdvancedDynamicTexture to instrument
  59009. */
  59010. constructor(
  59011. /**
  59012. * Define the instrumented AdvancedDynamicTexture.
  59013. */
  59014. texture: AdvancedDynamicTexture);
  59015. /**
  59016. * Dispose and release associated resources.
  59017. */
  59018. dispose(): void;
  59019. }
  59020. }
  59021. declare module BABYLON.GUI {
  59022. /**
  59023. * Class used to create containers for controls
  59024. */
  59025. export class Container3D extends Control3D {
  59026. private _blockLayout;
  59027. /**
  59028. * Gets the list of child controls
  59029. */
  59030. protected _children: Control3D[];
  59031. /**
  59032. * Gets the list of child controls
  59033. */
  59034. readonly children: Array<Control3D>;
  59035. /**
  59036. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  59037. * This is helpful to optimize layout operation when adding multiple children in a row
  59038. */
  59039. blockLayout: boolean;
  59040. /**
  59041. * Creates a new container
  59042. * @param name defines the container name
  59043. */
  59044. constructor(name?: string);
  59045. /**
  59046. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  59047. * @returns the current container
  59048. */
  59049. updateLayout(): Container3D;
  59050. /**
  59051. * Gets a boolean indicating if the given control is in the children of this control
  59052. * @param control defines the control to check
  59053. * @returns true if the control is in the child list
  59054. */
  59055. containsControl(control: Control3D): boolean;
  59056. /**
  59057. * Adds a control to the children of this control
  59058. * @param control defines the control to add
  59059. * @returns the current container
  59060. */
  59061. addControl(control: Control3D): Container3D;
  59062. /**
  59063. * This function will be called everytime a new control is added
  59064. */
  59065. protected _arrangeChildren(): void;
  59066. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  59067. /**
  59068. * Removes a control from the children of this control
  59069. * @param control defines the control to remove
  59070. * @returns the current container
  59071. */
  59072. removeControl(control: Control3D): Container3D;
  59073. protected _getTypeName(): string;
  59074. /**
  59075. * Releases all associated resources
  59076. */
  59077. dispose(): void;
  59078. /** Control rotation will remain unchanged */
  59079. static readonly UNSET_ORIENTATION: number;
  59080. /** Control will rotate to make it look at sphere central axis */
  59081. static readonly FACEORIGIN_ORIENTATION: number;
  59082. /** Control will rotate to make it look back at sphere central axis */
  59083. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  59084. /** Control will rotate to look at z axis (0, 0, 1) */
  59085. static readonly FACEFORWARD_ORIENTATION: number;
  59086. /** Control will rotate to look at negative z axis (0, 0, -1) */
  59087. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  59088. }
  59089. }
  59090. declare module BABYLON.GUI {
  59091. /**
  59092. * Class used to manage 3D user interface
  59093. * @see http://doc.babylonjs.com/how_to/gui3d
  59094. */
  59095. export class GUI3DManager implements BABYLON.IDisposable {
  59096. private _scene;
  59097. private _sceneDisposeObserver;
  59098. private _utilityLayer;
  59099. private _rootContainer;
  59100. private _pointerObserver;
  59101. private _pointerOutObserver;
  59102. /** @hidden */ lastPickedControl: Control3D;
  59103. /** @hidden */ lastControlOver: {
  59104. [pointerId: number]: Control3D;
  59105. };
  59106. /** @hidden */ lastControlDown: {
  59107. [pointerId: number]: Control3D;
  59108. };
  59109. /**
  59110. * BABYLON.Observable raised when the point picked by the pointer events changed
  59111. */
  59112. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  59113. /** @hidden */ sharedMaterials: {
  59114. [key: string]: BABYLON.Material;
  59115. };
  59116. /** Gets the hosting scene */
  59117. readonly scene: BABYLON.Scene;
  59118. /** Gets associated utility layer */
  59119. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  59120. /**
  59121. * Creates a new GUI3DManager
  59122. * @param scene
  59123. */
  59124. constructor(scene?: BABYLON.Scene);
  59125. private _handlePointerOut;
  59126. private _doPicking;
  59127. /**
  59128. * Gets the root container
  59129. */
  59130. readonly rootContainer: Container3D;
  59131. /**
  59132. * Gets a boolean indicating if the given control is in the root child list
  59133. * @param control defines the control to check
  59134. * @returns true if the control is in the root child list
  59135. */
  59136. containsControl(control: Control3D): boolean;
  59137. /**
  59138. * Adds a control to the root child list
  59139. * @param control defines the control to add
  59140. * @returns the current manager
  59141. */
  59142. addControl(control: Control3D): GUI3DManager;
  59143. /**
  59144. * Removes a control from the root child list
  59145. * @param control defines the control to remove
  59146. * @returns the current container
  59147. */
  59148. removeControl(control: Control3D): GUI3DManager;
  59149. /**
  59150. * Releases all associated resources
  59151. */
  59152. dispose(): void;
  59153. }
  59154. }
  59155. declare module BABYLON.GUI {
  59156. /**
  59157. * Class used to transport BABYLON.Vector3 information for pointer events
  59158. */
  59159. export class Vector3WithInfo extends BABYLON.Vector3 {
  59160. /** defines the current mouse button index */
  59161. buttonIndex: number;
  59162. /**
  59163. * Creates a new Vector3WithInfo
  59164. * @param source defines the vector3 data to transport
  59165. * @param buttonIndex defines the current mouse button index
  59166. */
  59167. constructor(source: BABYLON.Vector3,
  59168. /** defines the current mouse button index */
  59169. buttonIndex?: number);
  59170. }
  59171. }
  59172. declare module BABYLON.GUI {
  59173. /**
  59174. * Class used as base class for controls
  59175. */
  59176. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  59177. /** Defines the control name */
  59178. name?: string | undefined;
  59179. /** @hidden */ host: GUI3DManager;
  59180. private _node;
  59181. private _downCount;
  59182. private _enterCount;
  59183. private _downPointerIds;
  59184. private _isVisible;
  59185. /** Gets or sets the control position in world space */
  59186. position: BABYLON.Vector3;
  59187. /** Gets or sets the control scaling in world space */
  59188. scaling: BABYLON.Vector3;
  59189. /** Callback used to start pointer enter animation */
  59190. pointerEnterAnimation: () => void;
  59191. /** Callback used to start pointer out animation */
  59192. pointerOutAnimation: () => void;
  59193. /** Callback used to start pointer down animation */
  59194. pointerDownAnimation: () => void;
  59195. /** Callback used to start pointer up animation */
  59196. pointerUpAnimation: () => void;
  59197. /**
  59198. * An event triggered when the pointer move over the control
  59199. */
  59200. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  59201. /**
  59202. * An event triggered when the pointer move out of the control
  59203. */
  59204. onPointerOutObservable: BABYLON.Observable<Control3D>;
  59205. /**
  59206. * An event triggered when the pointer taps the control
  59207. */
  59208. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  59209. /**
  59210. * An event triggered when pointer is up
  59211. */
  59212. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  59213. /**
  59214. * An event triggered when a control is clicked on (with a mouse)
  59215. */
  59216. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  59217. /**
  59218. * An event triggered when pointer enters the control
  59219. */
  59220. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  59221. /**
  59222. * Gets or sets the parent container
  59223. */
  59224. parent: BABYLON.Nullable<Container3D>;
  59225. private _behaviors;
  59226. /**
  59227. * Gets the list of attached behaviors
  59228. * @see http://doc.babylonjs.com/features/behaviour
  59229. */
  59230. readonly behaviors: BABYLON.Behavior<Control3D>[];
  59231. /**
  59232. * Attach a behavior to the control
  59233. * @see http://doc.babylonjs.com/features/behaviour
  59234. * @param behavior defines the behavior to attach
  59235. * @returns the current control
  59236. */
  59237. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59238. /**
  59239. * Remove an attached behavior
  59240. * @see http://doc.babylonjs.com/features/behaviour
  59241. * @param behavior defines the behavior to attach
  59242. * @returns the current control
  59243. */
  59244. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59245. /**
  59246. * Gets an attached behavior by name
  59247. * @param name defines the name of the behavior to look for
  59248. * @see http://doc.babylonjs.com/features/behaviour
  59249. * @returns null if behavior was not found else the requested behavior
  59250. */
  59251. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  59252. /** Gets or sets a boolean indicating if the control is visible */
  59253. isVisible: boolean;
  59254. /**
  59255. * Creates a new control
  59256. * @param name defines the control name
  59257. */
  59258. constructor(
  59259. /** Defines the control name */
  59260. name?: string | undefined);
  59261. /**
  59262. * Gets a string representing the class name
  59263. */
  59264. readonly typeName: string;
  59265. /**
  59266. * Get the current class name of the control.
  59267. * @returns current class name
  59268. */
  59269. getClassName(): string;
  59270. protected _getTypeName(): string;
  59271. /**
  59272. * Gets the transform node used by this control
  59273. */
  59274. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  59275. /**
  59276. * Gets the mesh used to render this control
  59277. */
  59278. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59279. /**
  59280. * Link the control as child of the given node
  59281. * @param node defines the node to link to. Use null to unlink the control
  59282. * @returns the current control
  59283. */
  59284. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  59285. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  59286. /**
  59287. * Node creation.
  59288. * Can be overriden by children
  59289. * @param scene defines the scene where the node must be attached
  59290. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  59291. */
  59292. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  59293. /**
  59294. * Affect a material to the given mesh
  59295. * @param mesh defines the mesh which will represent the control
  59296. */
  59297. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59298. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  59299. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  59300. /** @hidden */ onPointerOut(target: Control3D): void;
  59301. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59302. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59303. /** @hidden */
  59304. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  59305. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59306. /** @hidden */ disposeNode(): void;
  59307. /**
  59308. * Releases all associated resources
  59309. */
  59310. dispose(): void;
  59311. }
  59312. }
  59313. declare module BABYLON.GUI {
  59314. /**
  59315. * Class used as a root to all buttons
  59316. */
  59317. export class AbstractButton3D extends Control3D {
  59318. /**
  59319. * Creates a new button
  59320. * @param name defines the control name
  59321. */
  59322. constructor(name?: string);
  59323. protected _getTypeName(): string;
  59324. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59325. }
  59326. }
  59327. declare module BABYLON.GUI {
  59328. /**
  59329. * Class used to create a button in 3D
  59330. */
  59331. export class Button3D extends AbstractButton3D {
  59332. /** @hidden */
  59333. protected _currentMaterial: BABYLON.Material;
  59334. private _facadeTexture;
  59335. private _content;
  59336. private _contentResolution;
  59337. private _contentScaleRatio;
  59338. /**
  59339. * Gets or sets the texture resolution used to render content (512 by default)
  59340. */
  59341. contentResolution: BABYLON.int;
  59342. /**
  59343. * Gets or sets the texture scale ratio used to render content (2 by default)
  59344. */
  59345. contentScaleRatio: number;
  59346. protected _disposeFacadeTexture(): void;
  59347. protected _resetContent(): void;
  59348. /**
  59349. * Creates a new button
  59350. * @param name defines the control name
  59351. */
  59352. constructor(name?: string);
  59353. /**
  59354. * Gets or sets the GUI 2D content used to display the button's facade
  59355. */
  59356. content: Control;
  59357. /**
  59358. * Apply the facade texture (created from the content property).
  59359. * This function can be overloaded by child classes
  59360. * @param facadeTexture defines the AdvancedDynamicTexture to use
  59361. */
  59362. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59363. protected _getTypeName(): string;
  59364. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59365. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59366. /**
  59367. * Releases all associated resources
  59368. */
  59369. dispose(): void;
  59370. }
  59371. }
  59372. declare module BABYLON.GUI {
  59373. /**
  59374. * Abstract class used to create a container panel deployed on the surface of a volume
  59375. */
  59376. export abstract class VolumeBasedPanel extends Container3D {
  59377. private _columns;
  59378. private _rows;
  59379. private _rowThenColum;
  59380. private _orientation;
  59381. protected _cellWidth: number;
  59382. protected _cellHeight: number;
  59383. /**
  59384. * Gets or sets the distance between elements
  59385. */
  59386. margin: number;
  59387. /**
  59388. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  59389. * | Value | Type | Description |
  59390. * | ----- | ----------------------------------- | ----------- |
  59391. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  59392. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  59393. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  59394. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  59395. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  59396. */
  59397. orientation: number;
  59398. /**
  59399. * Gets or sets the number of columns requested (10 by default).
  59400. * The panel will automatically compute the number of rows based on number of child controls.
  59401. */
  59402. columns: BABYLON.int;
  59403. /**
  59404. * Gets or sets a the number of rows requested.
  59405. * The panel will automatically compute the number of columns based on number of child controls.
  59406. */
  59407. rows: BABYLON.int;
  59408. /**
  59409. * Creates new VolumeBasedPanel
  59410. */
  59411. constructor();
  59412. protected _arrangeChildren(): void;
  59413. /** Child classes must implement this function to provide correct control positioning */
  59414. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59415. /** Child classes can implement this function to provide additional processing */
  59416. protected _finalProcessing(): void;
  59417. }
  59418. }
  59419. declare module BABYLON.GUI {
  59420. /**
  59421. * Class used to create a container panel deployed on the surface of a cylinder
  59422. */
  59423. export class CylinderPanel extends VolumeBasedPanel {
  59424. private _radius;
  59425. /**
  59426. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  59427. */
  59428. radius: BABYLON.float;
  59429. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59430. private _cylindricalMapping;
  59431. }
  59432. }
  59433. declare module BABYLON.GUI {
  59434. /** @hidden */
  59435. export var fluentVertexShader: {
  59436. name: string;
  59437. shader: string;
  59438. };
  59439. }
  59440. declare module BABYLON.GUI {
  59441. /** @hidden */
  59442. export var fluentPixelShader: {
  59443. name: string;
  59444. shader: string;
  59445. };
  59446. }
  59447. declare module BABYLON.GUI {
  59448. /** @hidden */
  59449. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  59450. INNERGLOW: boolean;
  59451. BORDER: boolean;
  59452. HOVERLIGHT: boolean;
  59453. TEXTURE: boolean;
  59454. constructor();
  59455. }
  59456. /**
  59457. * Class used to render controls with fluent desgin
  59458. */
  59459. export class FluentMaterial extends BABYLON.PushMaterial {
  59460. /**
  59461. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  59462. */
  59463. innerGlowColorIntensity: number;
  59464. /**
  59465. * Gets or sets the inner glow color (white by default)
  59466. */
  59467. innerGlowColor: BABYLON.Color3;
  59468. /**
  59469. * Gets or sets alpha value (default is 1.0)
  59470. */
  59471. alpha: number;
  59472. /**
  59473. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  59474. */
  59475. albedoColor: BABYLON.Color3;
  59476. /**
  59477. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  59478. */
  59479. renderBorders: boolean;
  59480. /**
  59481. * Gets or sets border width (default is 0.5)
  59482. */
  59483. borderWidth: number;
  59484. /**
  59485. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  59486. */
  59487. edgeSmoothingValue: number;
  59488. /**
  59489. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  59490. */
  59491. borderMinValue: number;
  59492. /**
  59493. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  59494. */
  59495. renderHoverLight: boolean;
  59496. /**
  59497. * Gets or sets the radius used to render the hover light (default is 1.0)
  59498. */
  59499. hoverRadius: number;
  59500. /**
  59501. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  59502. */
  59503. hoverColor: BABYLON.Color4;
  59504. /**
  59505. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  59506. */
  59507. hoverPosition: BABYLON.Vector3;
  59508. private _albedoTexture;
  59509. /** Gets or sets the texture to use for albedo color */
  59510. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  59511. /**
  59512. * Creates a new Fluent material
  59513. * @param name defines the name of the material
  59514. * @param scene defines the hosting scene
  59515. */
  59516. constructor(name: string, scene: BABYLON.Scene);
  59517. needAlphaBlending(): boolean;
  59518. needAlphaTesting(): boolean;
  59519. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  59520. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  59521. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  59522. getActiveTextures(): BABYLON.BaseTexture[];
  59523. hasTexture(texture: BABYLON.BaseTexture): boolean;
  59524. dispose(forceDisposeEffect?: boolean): void;
  59525. clone(name: string): FluentMaterial;
  59526. serialize(): any;
  59527. getClassName(): string;
  59528. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  59529. }
  59530. }
  59531. declare module BABYLON.GUI {
  59532. /**
  59533. * Class used to create a holographic button in 3D
  59534. */
  59535. export class HolographicButton extends Button3D {
  59536. private _backPlate;
  59537. private _textPlate;
  59538. private _frontPlate;
  59539. private _text;
  59540. private _imageUrl;
  59541. private _shareMaterials;
  59542. private _frontMaterial;
  59543. private _backMaterial;
  59544. private _plateMaterial;
  59545. private _pickedPointObserver;
  59546. private _tooltipFade;
  59547. private _tooltipTextBlock;
  59548. private _tooltipTexture;
  59549. private _tooltipMesh;
  59550. private _tooltipHoverObserver;
  59551. private _tooltipOutObserver;
  59552. private _disposeTooltip;
  59553. /**
  59554. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  59555. */
  59556. tooltipText: BABYLON.Nullable<string>;
  59557. /**
  59558. * Gets or sets text for the button
  59559. */
  59560. text: string;
  59561. /**
  59562. * Gets or sets the image url for the button
  59563. */
  59564. imageUrl: string;
  59565. /**
  59566. * Gets the back material used by this button
  59567. */
  59568. readonly backMaterial: FluentMaterial;
  59569. /**
  59570. * Gets the front material used by this button
  59571. */
  59572. readonly frontMaterial: FluentMaterial;
  59573. /**
  59574. * Gets the plate material used by this button
  59575. */
  59576. readonly plateMaterial: BABYLON.StandardMaterial;
  59577. /**
  59578. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  59579. */
  59580. readonly shareMaterials: boolean;
  59581. /**
  59582. * Creates a new button
  59583. * @param name defines the control name
  59584. */
  59585. constructor(name?: string, shareMaterials?: boolean);
  59586. protected _getTypeName(): string;
  59587. private _rebuildContent;
  59588. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59589. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59590. private _createBackMaterial;
  59591. private _createFrontMaterial;
  59592. private _createPlateMaterial;
  59593. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  59594. /**
  59595. * Releases all associated resources
  59596. */
  59597. dispose(): void;
  59598. }
  59599. }
  59600. declare module BABYLON.GUI {
  59601. /**
  59602. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  59603. */
  59604. export class MeshButton3D extends Button3D {
  59605. /** @hidden */
  59606. protected _currentMesh: BABYLON.Mesh;
  59607. /**
  59608. * Creates a new 3D button based on a mesh
  59609. * @param mesh mesh to become a 3D button
  59610. * @param name defines the control name
  59611. */
  59612. constructor(mesh: BABYLON.Mesh, name?: string);
  59613. protected _getTypeName(): string;
  59614. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59615. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59616. }
  59617. }
  59618. declare module BABYLON.GUI {
  59619. /**
  59620. * Class used to create a container panel deployed on the surface of a plane
  59621. */
  59622. export class PlanePanel extends VolumeBasedPanel {
  59623. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59624. }
  59625. }
  59626. declare module BABYLON.GUI {
  59627. /**
  59628. * Class used to create a container panel where items get randomized planar mapping
  59629. */
  59630. export class ScatterPanel extends VolumeBasedPanel {
  59631. private _iteration;
  59632. /**
  59633. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  59634. */
  59635. iteration: BABYLON.float;
  59636. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59637. private _scatterMapping;
  59638. protected _finalProcessing(): void;
  59639. }
  59640. }
  59641. declare module BABYLON.GUI {
  59642. /**
  59643. * Class used to create a container panel deployed on the surface of a sphere
  59644. */
  59645. export class SpherePanel extends VolumeBasedPanel {
  59646. private _radius;
  59647. /**
  59648. * Gets or sets the radius of the sphere where to project controls (5 by default)
  59649. */
  59650. radius: BABYLON.float;
  59651. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59652. private _sphericalMapping;
  59653. }
  59654. }
  59655. declare module BABYLON.GUI {
  59656. /**
  59657. * Class used to create a stack panel in 3D on XY plane
  59658. */
  59659. export class StackPanel3D extends Container3D {
  59660. private _isVertical;
  59661. /**
  59662. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  59663. */
  59664. isVertical: boolean;
  59665. /**
  59666. * Gets or sets the distance between elements
  59667. */
  59668. margin: number;
  59669. /**
  59670. * Creates new StackPanel
  59671. * @param isVertical
  59672. */
  59673. constructor(isVertical?: boolean);
  59674. protected _arrangeChildren(): void;
  59675. }
  59676. }
  59677. declare module BABYLON {
  59678. /**
  59679. * Mode that determines the coordinate system to use.
  59680. */
  59681. export enum GLTFLoaderCoordinateSystemMode {
  59682. /**
  59683. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  59684. */
  59685. AUTO = 0,
  59686. /**
  59687. * Sets the useRightHandedSystem flag on the scene.
  59688. */
  59689. FORCE_RIGHT_HANDED = 1
  59690. }
  59691. /**
  59692. * Mode that determines what animations will start.
  59693. */
  59694. export enum GLTFLoaderAnimationStartMode {
  59695. /**
  59696. * No animation will start.
  59697. */
  59698. NONE = 0,
  59699. /**
  59700. * The first animation will start.
  59701. */
  59702. FIRST = 1,
  59703. /**
  59704. * All animations will start.
  59705. */
  59706. ALL = 2
  59707. }
  59708. /**
  59709. * Interface that contains the data for the glTF asset.
  59710. */
  59711. export interface IGLTFLoaderData {
  59712. /**
  59713. * Object that represents the glTF JSON.
  59714. */
  59715. json: Object;
  59716. /**
  59717. * The BIN chunk of a binary glTF.
  59718. */
  59719. bin: Nullable<ArrayBufferView>;
  59720. }
  59721. /**
  59722. * Interface for extending the loader.
  59723. */
  59724. export interface IGLTFLoaderExtension {
  59725. /**
  59726. * The name of this extension.
  59727. */
  59728. readonly name: string;
  59729. /**
  59730. * Defines whether this extension is enabled.
  59731. */
  59732. enabled: boolean;
  59733. }
  59734. /**
  59735. * Loader state.
  59736. */
  59737. export enum GLTFLoaderState {
  59738. /**
  59739. * The asset is loading.
  59740. */
  59741. LOADING = 0,
  59742. /**
  59743. * The asset is ready for rendering.
  59744. */
  59745. READY = 1,
  59746. /**
  59747. * The asset is completely loaded.
  59748. */
  59749. COMPLETE = 2
  59750. }
  59751. /** @hidden */
  59752. export interface IGLTFLoader extends IDisposable {
  59753. readonly state: Nullable<GLTFLoaderState>;
  59754. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  59755. meshes: AbstractMesh[];
  59756. particleSystems: IParticleSystem[];
  59757. skeletons: Skeleton[];
  59758. animationGroups: AnimationGroup[];
  59759. }>;
  59760. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  59761. }
  59762. /**
  59763. * File loader for loading glTF files into a scene.
  59764. */
  59765. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  59766. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59767. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59768. /**
  59769. * Raised when the asset has been parsed
  59770. */
  59771. onParsedObservable: Observable<IGLTFLoaderData>;
  59772. private _onParsedObserver;
  59773. /**
  59774. * Raised when the asset has been parsed
  59775. */
  59776. onParsed: (loaderData: IGLTFLoaderData) => void;
  59777. /**
  59778. * 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.
  59779. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  59780. * Defaults to true.
  59781. * @hidden
  59782. */
  59783. static IncrementalLoading: boolean;
  59784. /**
  59785. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  59786. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  59787. * @hidden
  59788. */
  59789. static HomogeneousCoordinates: boolean;
  59790. /**
  59791. * The coordinate system mode. Defaults to AUTO.
  59792. */
  59793. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  59794. /**
  59795. * The animation start mode. Defaults to FIRST.
  59796. */
  59797. animationStartMode: GLTFLoaderAnimationStartMode;
  59798. /**
  59799. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  59800. */
  59801. compileMaterials: boolean;
  59802. /**
  59803. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  59804. */
  59805. useClipPlane: boolean;
  59806. /**
  59807. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  59808. */
  59809. compileShadowGenerators: boolean;
  59810. /**
  59811. * Defines if the Alpha blended materials are only applied as coverage.
  59812. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  59813. * If true, no extra effects are applied to transparent pixels.
  59814. */
  59815. transparencyAsCoverage: boolean;
  59816. /**
  59817. * Function called before loading a url referenced by the asset.
  59818. */
  59819. preprocessUrlAsync: (url: string) => Promise<string>;
  59820. /**
  59821. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59822. */
  59823. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  59824. private _onMeshLoadedObserver;
  59825. /**
  59826. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59827. */
  59828. onMeshLoaded: (mesh: AbstractMesh) => void;
  59829. /**
  59830. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  59831. */
  59832. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  59833. private _onTextureLoadedObserver;
  59834. /**
  59835. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  59836. */
  59837. onTextureLoaded: (texture: BaseTexture) => void;
  59838. /**
  59839. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  59840. */
  59841. readonly onMaterialLoadedObservable: Observable<Material>;
  59842. private _onMaterialLoadedObserver;
  59843. /**
  59844. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  59845. */
  59846. onMaterialLoaded: (material: Material) => void;
  59847. /**
  59848. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  59849. */
  59850. readonly onCameraLoadedObservable: Observable<Camera>;
  59851. private _onCameraLoadedObserver;
  59852. /**
  59853. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  59854. */
  59855. onCameraLoaded: (camera: Camera) => void;
  59856. /**
  59857. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  59858. * For assets with LODs, raised when all of the LODs are complete.
  59859. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59860. */
  59861. readonly onCompleteObservable: Observable<void>;
  59862. private _onCompleteObserver;
  59863. /**
  59864. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  59865. * For assets with LODs, raised when all of the LODs are complete.
  59866. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59867. */
  59868. onComplete: () => void;
  59869. /**
  59870. * Observable raised when an error occurs.
  59871. */
  59872. readonly onErrorObservable: Observable<any>;
  59873. private _onErrorObserver;
  59874. /**
  59875. * Callback raised when an error occurs.
  59876. */
  59877. onError: (reason: any) => void;
  59878. /**
  59879. * Observable raised after the loader is disposed.
  59880. */
  59881. readonly onDisposeObservable: Observable<void>;
  59882. private _onDisposeObserver;
  59883. /**
  59884. * Callback raised after the loader is disposed.
  59885. */
  59886. onDispose: () => void;
  59887. /**
  59888. * Observable raised after a loader extension is created.
  59889. * Set additional options for a loader extension in this event.
  59890. */
  59891. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  59892. private _onExtensionLoadedObserver;
  59893. /**
  59894. * Callback raised after a loader extension is created.
  59895. */
  59896. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  59897. /**
  59898. * Defines if the loader logging is enabled.
  59899. */
  59900. loggingEnabled: boolean;
  59901. /**
  59902. * Defines if the loader should capture performance counters.
  59903. */
  59904. capturePerformanceCounters: boolean;
  59905. /**
  59906. * Defines if the loader should validate the asset.
  59907. */
  59908. validate: boolean;
  59909. /**
  59910. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  59911. */
  59912. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  59913. private _onValidatedObserver;
  59914. /**
  59915. * Callback raised after a loader extension is created.
  59916. */
  59917. onValidated: (results: IGLTFValidationResults) => void;
  59918. private _loader;
  59919. /**
  59920. * Name of the loader ("gltf")
  59921. */
  59922. name: string;
  59923. /**
  59924. * Supported file extensions of the loader (.gltf, .glb)
  59925. */
  59926. extensions: ISceneLoaderPluginExtensions;
  59927. /**
  59928. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  59929. */
  59930. dispose(): void;
  59931. /** @hidden */ clear(): void;
  59932. /**
  59933. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  59934. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  59935. * @param scene the scene the meshes should be added to
  59936. * @param data the glTF data to load
  59937. * @param rootUrl root url to load from
  59938. * @param onProgress event that fires when loading progress has occured
  59939. * @param fileName Defines the name of the file to load
  59940. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  59941. */
  59942. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  59943. meshes: AbstractMesh[];
  59944. particleSystems: IParticleSystem[];
  59945. skeletons: Skeleton[];
  59946. animationGroups: AnimationGroup[];
  59947. }>;
  59948. /**
  59949. * Imports all objects from the loaded glTF data and adds them to the scene
  59950. * @param scene the scene the objects should be added to
  59951. * @param data the glTF data to load
  59952. * @param rootUrl root url to load from
  59953. * @param onProgress event that fires when loading progress has occured
  59954. * @param fileName Defines the name of the file to load
  59955. * @returns a promise which completes when objects have been loaded to the scene
  59956. */
  59957. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  59958. /**
  59959. * Load into an asset container.
  59960. * @param scene The scene to load into
  59961. * @param data The data to import
  59962. * @param rootUrl The root url for scene and resources
  59963. * @param onProgress The callback when the load progresses
  59964. * @param fileName Defines the name of the file to load
  59965. * @returns The loaded asset container
  59966. */
  59967. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  59968. /**
  59969. * If the data string can be loaded directly.
  59970. * @param data string contianing the file data
  59971. * @returns if the data can be loaded directly
  59972. */
  59973. canDirectLoad(data: string): boolean;
  59974. /**
  59975. * Rewrites a url by combining a root url and response url.
  59976. */
  59977. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  59978. /**
  59979. * Instantiates a glTF file loader plugin.
  59980. * @returns the created plugin
  59981. */
  59982. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  59983. /**
  59984. * The loader state or null if the loader is not active.
  59985. */
  59986. readonly loaderState: Nullable<GLTFLoaderState>;
  59987. /**
  59988. * Returns a promise that resolves when the asset is completely loaded.
  59989. * @returns a promise that resolves when the asset is completely loaded.
  59990. */
  59991. whenCompleteAsync(): Promise<void>;
  59992. private _parseAsync;
  59993. private _validateAsync;
  59994. private _getLoader;
  59995. private _unpackBinary;
  59996. private _unpackBinaryV1;
  59997. private _unpackBinaryV2;
  59998. private static _parseVersion;
  59999. private static _compareVersion;
  60000. private static _decodeBufferToText;
  60001. private static readonly _logSpaces;
  60002. private _logIndentLevel;
  60003. private _loggingEnabled;
  60004. /** @hidden */ log: (message: string) => void;
  60005. /** @hidden */ logOpen(message: string): void;
  60006. /** @hidden */ logClose(): void;
  60007. private _logEnabled;
  60008. private _logDisabled;
  60009. private _capturePerformanceCounters;
  60010. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  60011. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  60012. private _startPerformanceCounterEnabled;
  60013. private _startPerformanceCounterDisabled;
  60014. private _endPerformanceCounterEnabled;
  60015. private _endPerformanceCounterDisabled;
  60016. }
  60017. }
  60018. declare module BABYLON.GLTF1 {
  60019. /**
  60020. * Enums
  60021. * @hidden
  60022. */
  60023. export enum EComponentType {
  60024. BYTE = 5120,
  60025. UNSIGNED_BYTE = 5121,
  60026. SHORT = 5122,
  60027. UNSIGNED_SHORT = 5123,
  60028. FLOAT = 5126
  60029. }
  60030. /** @hidden */
  60031. export enum EShaderType {
  60032. FRAGMENT = 35632,
  60033. VERTEX = 35633
  60034. }
  60035. /** @hidden */
  60036. export enum EParameterType {
  60037. BYTE = 5120,
  60038. UNSIGNED_BYTE = 5121,
  60039. SHORT = 5122,
  60040. UNSIGNED_SHORT = 5123,
  60041. INT = 5124,
  60042. UNSIGNED_INT = 5125,
  60043. FLOAT = 5126,
  60044. FLOAT_VEC2 = 35664,
  60045. FLOAT_VEC3 = 35665,
  60046. FLOAT_VEC4 = 35666,
  60047. INT_VEC2 = 35667,
  60048. INT_VEC3 = 35668,
  60049. INT_VEC4 = 35669,
  60050. BOOL = 35670,
  60051. BOOL_VEC2 = 35671,
  60052. BOOL_VEC3 = 35672,
  60053. BOOL_VEC4 = 35673,
  60054. FLOAT_MAT2 = 35674,
  60055. FLOAT_MAT3 = 35675,
  60056. FLOAT_MAT4 = 35676,
  60057. SAMPLER_2D = 35678
  60058. }
  60059. /** @hidden */
  60060. export enum ETextureWrapMode {
  60061. CLAMP_TO_EDGE = 33071,
  60062. MIRRORED_REPEAT = 33648,
  60063. REPEAT = 10497
  60064. }
  60065. /** @hidden */
  60066. export enum ETextureFilterType {
  60067. NEAREST = 9728,
  60068. LINEAR = 9728,
  60069. NEAREST_MIPMAP_NEAREST = 9984,
  60070. LINEAR_MIPMAP_NEAREST = 9985,
  60071. NEAREST_MIPMAP_LINEAR = 9986,
  60072. LINEAR_MIPMAP_LINEAR = 9987
  60073. }
  60074. /** @hidden */
  60075. export enum ETextureFormat {
  60076. ALPHA = 6406,
  60077. RGB = 6407,
  60078. RGBA = 6408,
  60079. LUMINANCE = 6409,
  60080. LUMINANCE_ALPHA = 6410
  60081. }
  60082. /** @hidden */
  60083. export enum ECullingType {
  60084. FRONT = 1028,
  60085. BACK = 1029,
  60086. FRONT_AND_BACK = 1032
  60087. }
  60088. /** @hidden */
  60089. export enum EBlendingFunction {
  60090. ZERO = 0,
  60091. ONE = 1,
  60092. SRC_COLOR = 768,
  60093. ONE_MINUS_SRC_COLOR = 769,
  60094. DST_COLOR = 774,
  60095. ONE_MINUS_DST_COLOR = 775,
  60096. SRC_ALPHA = 770,
  60097. ONE_MINUS_SRC_ALPHA = 771,
  60098. DST_ALPHA = 772,
  60099. ONE_MINUS_DST_ALPHA = 773,
  60100. CONSTANT_COLOR = 32769,
  60101. ONE_MINUS_CONSTANT_COLOR = 32770,
  60102. CONSTANT_ALPHA = 32771,
  60103. ONE_MINUS_CONSTANT_ALPHA = 32772,
  60104. SRC_ALPHA_SATURATE = 776
  60105. }
  60106. /** @hidden */
  60107. export interface IGLTFProperty {
  60108. extensions?: {
  60109. [key: string]: any;
  60110. };
  60111. extras?: Object;
  60112. }
  60113. /** @hidden */
  60114. export interface IGLTFChildRootProperty extends IGLTFProperty {
  60115. name?: string;
  60116. }
  60117. /** @hidden */
  60118. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  60119. bufferView: string;
  60120. byteOffset: number;
  60121. byteStride: number;
  60122. count: number;
  60123. type: string;
  60124. componentType: EComponentType;
  60125. max?: number[];
  60126. min?: number[];
  60127. name?: string;
  60128. }
  60129. /** @hidden */
  60130. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  60131. buffer: string;
  60132. byteOffset: number;
  60133. byteLength: number;
  60134. byteStride: number;
  60135. target?: number;
  60136. }
  60137. /** @hidden */
  60138. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  60139. uri: string;
  60140. byteLength?: number;
  60141. type?: string;
  60142. }
  60143. /** @hidden */
  60144. export interface IGLTFShader extends IGLTFChildRootProperty {
  60145. uri: string;
  60146. type: EShaderType;
  60147. }
  60148. /** @hidden */
  60149. export interface IGLTFProgram extends IGLTFChildRootProperty {
  60150. attributes: string[];
  60151. fragmentShader: string;
  60152. vertexShader: string;
  60153. }
  60154. /** @hidden */
  60155. export interface IGLTFTechniqueParameter {
  60156. type: number;
  60157. count?: number;
  60158. semantic?: string;
  60159. node?: string;
  60160. value?: number | boolean | string | Array<any>;
  60161. source?: string;
  60162. babylonValue?: any;
  60163. }
  60164. /** @hidden */
  60165. export interface IGLTFTechniqueCommonProfile {
  60166. lightingModel: string;
  60167. texcoordBindings: Object;
  60168. parameters?: Array<any>;
  60169. }
  60170. /** @hidden */
  60171. export interface IGLTFTechniqueStatesFunctions {
  60172. blendColor?: number[];
  60173. blendEquationSeparate?: number[];
  60174. blendFuncSeparate?: number[];
  60175. colorMask: boolean[];
  60176. cullFace: number[];
  60177. }
  60178. /** @hidden */
  60179. export interface IGLTFTechniqueStates {
  60180. enable: number[];
  60181. functions: IGLTFTechniqueStatesFunctions;
  60182. }
  60183. /** @hidden */
  60184. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  60185. parameters: {
  60186. [key: string]: IGLTFTechniqueParameter;
  60187. };
  60188. program: string;
  60189. attributes: {
  60190. [key: string]: string;
  60191. };
  60192. uniforms: {
  60193. [key: string]: string;
  60194. };
  60195. states: IGLTFTechniqueStates;
  60196. }
  60197. /** @hidden */
  60198. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  60199. technique?: string;
  60200. values: string[];
  60201. }
  60202. /** @hidden */
  60203. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  60204. attributes: {
  60205. [key: string]: string;
  60206. };
  60207. indices: string;
  60208. material: string;
  60209. mode?: number;
  60210. }
  60211. /** @hidden */
  60212. export interface IGLTFMesh extends IGLTFChildRootProperty {
  60213. primitives: IGLTFMeshPrimitive[];
  60214. }
  60215. /** @hidden */
  60216. export interface IGLTFImage extends IGLTFChildRootProperty {
  60217. uri: string;
  60218. }
  60219. /** @hidden */
  60220. export interface IGLTFSampler extends IGLTFChildRootProperty {
  60221. magFilter?: number;
  60222. minFilter?: number;
  60223. wrapS?: number;
  60224. wrapT?: number;
  60225. }
  60226. /** @hidden */
  60227. export interface IGLTFTexture extends IGLTFChildRootProperty {
  60228. sampler: string;
  60229. source: string;
  60230. format?: ETextureFormat;
  60231. internalFormat?: ETextureFormat;
  60232. target?: number;
  60233. type?: number;
  60234. babylonTexture?: Texture;
  60235. }
  60236. /** @hidden */
  60237. export interface IGLTFAmbienLight {
  60238. color?: number[];
  60239. }
  60240. /** @hidden */
  60241. export interface IGLTFDirectionalLight {
  60242. color?: number[];
  60243. }
  60244. /** @hidden */
  60245. export interface IGLTFPointLight {
  60246. color?: number[];
  60247. constantAttenuation?: number;
  60248. linearAttenuation?: number;
  60249. quadraticAttenuation?: number;
  60250. }
  60251. /** @hidden */
  60252. export interface IGLTFSpotLight {
  60253. color?: number[];
  60254. constantAttenuation?: number;
  60255. fallOfAngle?: number;
  60256. fallOffExponent?: number;
  60257. linearAttenuation?: number;
  60258. quadraticAttenuation?: number;
  60259. }
  60260. /** @hidden */
  60261. export interface IGLTFLight extends IGLTFChildRootProperty {
  60262. type: string;
  60263. }
  60264. /** @hidden */
  60265. export interface IGLTFCameraOrthographic {
  60266. xmag: number;
  60267. ymag: number;
  60268. zfar: number;
  60269. znear: number;
  60270. }
  60271. /** @hidden */
  60272. export interface IGLTFCameraPerspective {
  60273. aspectRatio: number;
  60274. yfov: number;
  60275. zfar: number;
  60276. znear: number;
  60277. }
  60278. /** @hidden */
  60279. export interface IGLTFCamera extends IGLTFChildRootProperty {
  60280. type: string;
  60281. }
  60282. /** @hidden */
  60283. export interface IGLTFAnimationChannelTarget {
  60284. id: string;
  60285. path: string;
  60286. }
  60287. /** @hidden */
  60288. export interface IGLTFAnimationChannel {
  60289. sampler: string;
  60290. target: IGLTFAnimationChannelTarget;
  60291. }
  60292. /** @hidden */
  60293. export interface IGLTFAnimationSampler {
  60294. input: string;
  60295. output: string;
  60296. interpolation?: string;
  60297. }
  60298. /** @hidden */
  60299. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  60300. channels?: IGLTFAnimationChannel[];
  60301. parameters?: {
  60302. [key: string]: string;
  60303. };
  60304. samplers?: {
  60305. [key: string]: IGLTFAnimationSampler;
  60306. };
  60307. }
  60308. /** @hidden */
  60309. export interface IGLTFNodeInstanceSkin {
  60310. skeletons: string[];
  60311. skin: string;
  60312. meshes: string[];
  60313. }
  60314. /** @hidden */
  60315. export interface IGLTFSkins extends IGLTFChildRootProperty {
  60316. bindShapeMatrix: number[];
  60317. inverseBindMatrices: string;
  60318. jointNames: string[];
  60319. babylonSkeleton?: Skeleton;
  60320. }
  60321. /** @hidden */
  60322. export interface IGLTFNode extends IGLTFChildRootProperty {
  60323. camera?: string;
  60324. children: string[];
  60325. skin?: string;
  60326. jointName?: string;
  60327. light?: string;
  60328. matrix: number[];
  60329. mesh?: string;
  60330. meshes?: string[];
  60331. rotation?: number[];
  60332. scale?: number[];
  60333. translation?: number[];
  60334. babylonNode?: Node;
  60335. }
  60336. /** @hidden */
  60337. export interface IGLTFScene extends IGLTFChildRootProperty {
  60338. nodes: string[];
  60339. }
  60340. /** @hidden */
  60341. export interface IGLTFRuntime {
  60342. extensions: {
  60343. [key: string]: any;
  60344. };
  60345. accessors: {
  60346. [key: string]: IGLTFAccessor;
  60347. };
  60348. buffers: {
  60349. [key: string]: IGLTFBuffer;
  60350. };
  60351. bufferViews: {
  60352. [key: string]: IGLTFBufferView;
  60353. };
  60354. meshes: {
  60355. [key: string]: IGLTFMesh;
  60356. };
  60357. lights: {
  60358. [key: string]: IGLTFLight;
  60359. };
  60360. cameras: {
  60361. [key: string]: IGLTFCamera;
  60362. };
  60363. nodes: {
  60364. [key: string]: IGLTFNode;
  60365. };
  60366. images: {
  60367. [key: string]: IGLTFImage;
  60368. };
  60369. textures: {
  60370. [key: string]: IGLTFTexture;
  60371. };
  60372. shaders: {
  60373. [key: string]: IGLTFShader;
  60374. };
  60375. programs: {
  60376. [key: string]: IGLTFProgram;
  60377. };
  60378. samplers: {
  60379. [key: string]: IGLTFSampler;
  60380. };
  60381. techniques: {
  60382. [key: string]: IGLTFTechnique;
  60383. };
  60384. materials: {
  60385. [key: string]: IGLTFMaterial;
  60386. };
  60387. animations: {
  60388. [key: string]: IGLTFAnimation;
  60389. };
  60390. skins: {
  60391. [key: string]: IGLTFSkins;
  60392. };
  60393. currentScene?: Object;
  60394. scenes: {
  60395. [key: string]: IGLTFScene;
  60396. };
  60397. extensionsUsed: string[];
  60398. extensionsRequired?: string[];
  60399. buffersCount: number;
  60400. shaderscount: number;
  60401. scene: Scene;
  60402. rootUrl: string;
  60403. loadedBufferCount: number;
  60404. loadedBufferViews: {
  60405. [name: string]: ArrayBufferView;
  60406. };
  60407. loadedShaderCount: number;
  60408. importOnlyMeshes: boolean;
  60409. importMeshesNames?: string[];
  60410. dummyNodes: Node[];
  60411. }
  60412. /** @hidden */
  60413. export interface INodeToRoot {
  60414. bone: Bone;
  60415. node: IGLTFNode;
  60416. id: string;
  60417. }
  60418. /** @hidden */
  60419. export interface IJointNode {
  60420. node: IGLTFNode;
  60421. id: string;
  60422. }
  60423. }
  60424. declare module BABYLON.GLTF1 {
  60425. /**
  60426. * Utils functions for GLTF
  60427. * @hidden
  60428. */
  60429. export class GLTFUtils {
  60430. /**
  60431. * Sets the given "parameter" matrix
  60432. * @param scene: the Scene object
  60433. * @param source: the source node where to pick the matrix
  60434. * @param parameter: the GLTF technique parameter
  60435. * @param uniformName: the name of the shader's uniform
  60436. * @param shaderMaterial: the shader material
  60437. */
  60438. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  60439. /**
  60440. * Sets the given "parameter" matrix
  60441. * @param shaderMaterial: the shader material
  60442. * @param uniform: the name of the shader's uniform
  60443. * @param value: the value of the uniform
  60444. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  60445. */
  60446. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  60447. /**
  60448. * Returns the wrap mode of the texture
  60449. * @param mode: the mode value
  60450. */
  60451. static GetWrapMode(mode: number): number;
  60452. /**
  60453. * Returns the byte stride giving an accessor
  60454. * @param accessor: the GLTF accessor objet
  60455. */
  60456. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  60457. /**
  60458. * Returns the texture filter mode giving a mode value
  60459. * @param mode: the filter mode value
  60460. */
  60461. static GetTextureFilterMode(mode: number): ETextureFilterType;
  60462. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  60463. /**
  60464. * Returns a buffer from its accessor
  60465. * @param gltfRuntime: the GLTF runtime
  60466. * @param accessor: the GLTF accessor
  60467. */
  60468. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  60469. /**
  60470. * Decodes a buffer view into a string
  60471. * @param view: the buffer view
  60472. */
  60473. static DecodeBufferToText(view: ArrayBufferView): string;
  60474. /**
  60475. * Returns the default material of gltf. Related to
  60476. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  60477. * @param scene: the Babylon.js scene
  60478. */
  60479. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  60480. private static _DefaultMaterial;
  60481. }
  60482. }
  60483. declare module BABYLON.GLTF1 {
  60484. /**
  60485. * Implementation of the base glTF spec
  60486. * @hidden
  60487. */
  60488. export class GLTFLoaderBase {
  60489. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  60490. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60491. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  60492. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60493. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  60494. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60495. }
  60496. /**
  60497. * glTF V1 Loader
  60498. * @hidden
  60499. */
  60500. export class GLTFLoader implements IGLTFLoader {
  60501. static Extensions: {
  60502. [name: string]: GLTFLoaderExtension;
  60503. };
  60504. static RegisterExtension(extension: GLTFLoaderExtension): void;
  60505. state: Nullable<GLTFLoaderState>;
  60506. dispose(): void;
  60507. private _importMeshAsync;
  60508. /**
  60509. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  60510. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  60511. * @param scene the scene the meshes should be added to
  60512. * @param data gltf data containing information of the meshes in a loaded file
  60513. * @param rootUrl root url to load from
  60514. * @param onProgress event that fires when loading progress has occured
  60515. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  60516. */
  60517. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  60518. meshes: AbstractMesh[];
  60519. particleSystems: IParticleSystem[];
  60520. skeletons: Skeleton[];
  60521. animationGroups: AnimationGroup[];
  60522. }>;
  60523. private _loadAsync;
  60524. /**
  60525. * Imports all objects from a loaded gltf file and adds them to the scene
  60526. * @param scene the scene the objects should be added to
  60527. * @param data gltf data containing information of the meshes in a loaded file
  60528. * @param rootUrl root url to load from
  60529. * @param onProgress event that fires when loading progress has occured
  60530. * @returns a promise which completes when objects have been loaded to the scene
  60531. */
  60532. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  60533. private _loadShadersAsync;
  60534. private _loadBuffersAsync;
  60535. private _createNodes;
  60536. }
  60537. /** @hidden */
  60538. export abstract class GLTFLoaderExtension {
  60539. private _name;
  60540. constructor(name: string);
  60541. readonly name: string;
  60542. /**
  60543. * Defines an override for loading the runtime
  60544. * Return true to stop further extensions from loading the runtime
  60545. */
  60546. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  60547. /**
  60548. * Defines an onverride for creating gltf runtime
  60549. * Return true to stop further extensions from creating the runtime
  60550. */
  60551. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  60552. /**
  60553. * Defines an override for loading buffers
  60554. * Return true to stop further extensions from loading this buffer
  60555. */
  60556. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  60557. /**
  60558. * Defines an override for loading texture buffers
  60559. * Return true to stop further extensions from loading this texture data
  60560. */
  60561. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60562. /**
  60563. * Defines an override for creating textures
  60564. * Return true to stop further extensions from loading this texture
  60565. */
  60566. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  60567. /**
  60568. * Defines an override for loading shader strings
  60569. * Return true to stop further extensions from loading this shader data
  60570. */
  60571. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60572. /**
  60573. * Defines an override for loading materials
  60574. * Return true to stop further extensions from loading this material
  60575. */
  60576. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60577. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  60578. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  60579. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60580. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60581. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  60582. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60583. private static LoadTextureBufferAsync;
  60584. private static CreateTextureAsync;
  60585. private static ApplyExtensions;
  60586. }
  60587. }
  60588. declare module BABYLON.GLTF1 {
  60589. /** @hidden */
  60590. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  60591. private _bin;
  60592. constructor();
  60593. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  60594. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60595. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60596. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60597. }
  60598. }
  60599. declare module BABYLON.GLTF1 {
  60600. /** @hidden */
  60601. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  60602. constructor();
  60603. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  60604. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60605. private _loadTexture;
  60606. }
  60607. }
  60608. declare module BABYLON.GLTF2.Loader {
  60609. /**
  60610. * Loader interface with an index field.
  60611. */
  60612. export interface IArrayItem {
  60613. /**
  60614. * The index of this item in the array.
  60615. */
  60616. index: number;
  60617. }
  60618. /**
  60619. * Loader interface with additional members.
  60620. */
  60621. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  60622. /** @hidden */ data?: Promise<ArrayBufferView>;
  60623. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  60624. }
  60625. /**
  60626. * Loader interface with additional members.
  60627. */
  60628. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  60629. }
  60630. /** @hidden */
  60631. export interface _IAnimationSamplerData {
  60632. input: Float32Array;
  60633. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  60634. output: Float32Array;
  60635. }
  60636. /**
  60637. * Loader interface with additional members.
  60638. */
  60639. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  60640. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  60641. }
  60642. /**
  60643. * Loader interface with additional members.
  60644. */
  60645. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  60646. channels: IAnimationChannel[];
  60647. samplers: IAnimationSampler[];
  60648. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  60649. }
  60650. /**
  60651. * Loader interface with additional members.
  60652. */
  60653. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  60654. /** @hidden */ data?: Promise<ArrayBufferView>;
  60655. }
  60656. /**
  60657. * Loader interface with additional members.
  60658. */
  60659. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  60660. /** @hidden */ data?: Promise<ArrayBufferView>;
  60661. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  60662. }
  60663. /**
  60664. * Loader interface with additional members.
  60665. */
  60666. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  60667. }
  60668. /**
  60669. * Loader interface with additional members.
  60670. */
  60671. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  60672. /** @hidden */ data?: Promise<ArrayBufferView>;
  60673. }
  60674. /**
  60675. * Loader interface with additional members.
  60676. */
  60677. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  60678. }
  60679. /**
  60680. * Loader interface with additional members.
  60681. */
  60682. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  60683. }
  60684. /**
  60685. * Loader interface with additional members.
  60686. */
  60687. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  60688. baseColorTexture?: ITextureInfo;
  60689. metallicRoughnessTexture?: ITextureInfo;
  60690. }
  60691. /**
  60692. * Loader interface with additional members.
  60693. */
  60694. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  60695. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  60696. normalTexture?: IMaterialNormalTextureInfo;
  60697. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60698. emissiveTexture?: ITextureInfo;
  60699. /** @hidden */ data?: {
  60700. [babylonDrawMode: number]: {
  60701. babylonMaterial: Material;
  60702. babylonMeshes: AbstractMesh[];
  60703. promise: Promise<void>;
  60704. };
  60705. };
  60706. }
  60707. /**
  60708. * Loader interface with additional members.
  60709. */
  60710. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  60711. primitives: IMeshPrimitive[];
  60712. }
  60713. /**
  60714. * Loader interface with additional members.
  60715. */
  60716. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  60717. /** @hidden */ instanceData?: {
  60718. babylonSourceMesh: Mesh;
  60719. promise: Promise<any>;
  60720. };
  60721. }
  60722. /**
  60723. * Loader interface with additional members.
  60724. */
  60725. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  60726. /**
  60727. * The parent glTF node.
  60728. */
  60729. parent?: INode;
  60730. /** @hidden */ babylonTransformNode?: TransformNode;
  60731. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  60732. /** @hidden */ babylonBones?: Bone[];
  60733. /** @hidden */ numMorphTargets?: number;
  60734. }
  60735. /** @hidden */
  60736. export interface _ISamplerData {
  60737. noMipMaps: boolean;
  60738. samplingMode: number;
  60739. wrapU: number;
  60740. wrapV: number;
  60741. }
  60742. /**
  60743. * Loader interface with additional members.
  60744. */
  60745. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  60746. /** @hidden */ data?: _ISamplerData;
  60747. }
  60748. /**
  60749. * Loader interface with additional members.
  60750. */
  60751. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  60752. }
  60753. /**
  60754. * Loader interface with additional members.
  60755. */
  60756. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  60757. /** @hidden */ data?: {
  60758. babylonSkeleton: Skeleton;
  60759. promise: Promise<void>;
  60760. };
  60761. }
  60762. /**
  60763. * Loader interface with additional members.
  60764. */
  60765. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  60766. }
  60767. /**
  60768. * Loader interface with additional members.
  60769. */
  60770. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  60771. }
  60772. /**
  60773. * Loader interface with additional members.
  60774. */
  60775. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  60776. accessors?: IAccessor[];
  60777. animations?: IAnimation[];
  60778. buffers?: IBuffer[];
  60779. bufferViews?: IBufferView[];
  60780. cameras?: ICamera[];
  60781. images?: IImage[];
  60782. materials?: IMaterial[];
  60783. meshes?: IMesh[];
  60784. nodes?: INode[];
  60785. samplers?: ISampler[];
  60786. scenes?: IScene[];
  60787. skins?: ISkin[];
  60788. textures?: ITexture[];
  60789. }
  60790. }
  60791. declare module BABYLON.GLTF2 {
  60792. /**
  60793. * Interface for a glTF loader extension.
  60794. */
  60795. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  60796. /**
  60797. * Called after the loader state changes to LOADING.
  60798. */
  60799. onLoading?(): void;
  60800. /**
  60801. * Called after the loader state changes to READY.
  60802. */
  60803. onReady?(): void;
  60804. /**
  60805. * Define this method to modify the default behavior when loading scenes.
  60806. * @param context The context when loading the asset
  60807. * @param scene The glTF scene property
  60808. * @returns A promise that resolves when the load is complete or null if not handled
  60809. */
  60810. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  60811. /**
  60812. * Define this method to modify the default behavior when loading nodes.
  60813. * @param context The context when loading the asset
  60814. * @param node The glTF node property
  60815. * @param assign A function called synchronously after parsing the glTF properties
  60816. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  60817. */
  60818. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60819. /**
  60820. * Define this method to modify the default behavior when loading cameras.
  60821. * @param context The context when loading the asset
  60822. * @param camera The glTF camera property
  60823. * @param assign A function called synchronously after parsing the glTF properties
  60824. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  60825. */
  60826. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  60827. /**
  60828. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  60829. * @param context The context when loading the asset
  60830. * @param primitive The glTF mesh primitive property
  60831. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  60832. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60833. /**
  60834. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  60835. * @param context The context when loading the asset
  60836. * @param name The mesh name when loading the asset
  60837. * @param node The glTF node when loading the asset
  60838. * @param mesh The glTF mesh when loading the asset
  60839. * @param primitive The glTF mesh primitive property
  60840. * @param assign A function called synchronously after parsing the glTF properties
  60841. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  60842. */ loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  60843. /**
  60844. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  60845. * @param context The context when loading the asset
  60846. * @param material The glTF material property
  60847. * @param assign A function called synchronously after parsing the glTF properties
  60848. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  60849. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  60850. /**
  60851. * Define this method to modify the default behavior when creating materials.
  60852. * @param context The context when loading the asset
  60853. * @param material The glTF material property
  60854. * @param babylonDrawMode The draw mode for the Babylon material
  60855. * @returns The Babylon material or null if not handled
  60856. */
  60857. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  60858. /**
  60859. * Define this method to modify the default behavior when loading material properties.
  60860. * @param context The context when loading the asset
  60861. * @param material The glTF material property
  60862. * @param babylonMaterial The Babylon material
  60863. * @returns A promise that resolves when the load is complete or null if not handled
  60864. */
  60865. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60866. /**
  60867. * Define this method to modify the default behavior when loading texture infos.
  60868. * @param context The context when loading the asset
  60869. * @param textureInfo The glTF texture info property
  60870. * @param assign A function called synchronously after parsing the glTF properties
  60871. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  60872. */
  60873. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60874. /**
  60875. * Define this method to modify the default behavior when loading animations.
  60876. * @param context The context when loading the asset
  60877. * @param animation The glTF animation property
  60878. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  60879. */
  60880. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60881. /**
  60882. * @hidden Define this method to modify the default behavior when loading skins.
  60883. * @param context The context when loading the asset
  60884. * @param node The glTF node property
  60885. * @param skin The glTF skin property
  60886. * @returns A promise that resolves when the load is complete or null if not handled
  60887. */ loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  60888. /**
  60889. * @hidden Define this method to modify the default behavior when loading uris.
  60890. * @param context The context when loading the asset
  60891. * @param property The glTF property associated with the uri
  60892. * @param uri The uri to load
  60893. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  60894. */ loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  60895. }
  60896. }
  60897. declare module BABYLON.GLTF2 {
  60898. /**
  60899. * Helper class for working with arrays when loading the glTF asset
  60900. */
  60901. export class ArrayItem {
  60902. /**
  60903. * Gets an item from the given array.
  60904. * @param context The context when loading the asset
  60905. * @param array The array to get the item from
  60906. * @param index The index to the array
  60907. * @returns The array item
  60908. */
  60909. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  60910. /**
  60911. * Assign an `index` field to each item of the given array.
  60912. * @param array The array of items
  60913. */
  60914. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  60915. }
  60916. /**
  60917. * The glTF 2.0 loader
  60918. */
  60919. export class GLTFLoader implements IGLTFLoader {
  60920. /** @hidden */ completePromises: Promise<any>[];
  60921. private _disposed;
  60922. private _parent;
  60923. private _state;
  60924. private _extensions;
  60925. private _rootUrl;
  60926. private _fileName;
  60927. private _uniqueRootUrl;
  60928. private _gltf;
  60929. private _babylonScene;
  60930. private _rootBabylonMesh;
  60931. private _defaultBabylonMaterialData;
  60932. private _progressCallback?;
  60933. private _requests;
  60934. private static readonly _DefaultSampler;
  60935. private static _ExtensionNames;
  60936. private static _ExtensionFactories;
  60937. /**
  60938. * Registers a loader extension.
  60939. * @param name The name of the loader extension.
  60940. * @param factory The factory function that creates the loader extension.
  60941. */
  60942. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  60943. /**
  60944. * Unregisters a loader extension.
  60945. * @param name The name of the loader extenion.
  60946. * @returns A boolean indicating whether the extension has been unregistered
  60947. */
  60948. static UnregisterExtension(name: string): boolean;
  60949. /**
  60950. * Gets the loader state.
  60951. */
  60952. readonly state: Nullable<GLTFLoaderState>;
  60953. /**
  60954. * The glTF object parsed from the JSON.
  60955. */
  60956. readonly gltf: IGLTF;
  60957. /**
  60958. * The Babylon scene when loading the asset.
  60959. */
  60960. readonly babylonScene: Scene;
  60961. /**
  60962. * The root Babylon mesh when loading the asset.
  60963. */
  60964. readonly rootBabylonMesh: Mesh;
  60965. /** @hidden */
  60966. constructor(parent: GLTFFileLoader);
  60967. /** @hidden */
  60968. dispose(): void;
  60969. /** @hidden */
  60970. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  60971. meshes: AbstractMesh[];
  60972. particleSystems: IParticleSystem[];
  60973. skeletons: Skeleton[];
  60974. animationGroups: AnimationGroup[];
  60975. }>;
  60976. /** @hidden */
  60977. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  60978. private _loadAsync;
  60979. private _loadData;
  60980. private _setupData;
  60981. private _loadExtensions;
  60982. private _checkExtensions;
  60983. private _setState;
  60984. private _createRootNode;
  60985. /**
  60986. * Loads a glTF scene.
  60987. * @param context The context when loading the asset
  60988. * @param scene The glTF scene property
  60989. * @returns A promise that resolves when the load is complete
  60990. */
  60991. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  60992. private _forEachPrimitive;
  60993. private _getMeshes;
  60994. private _getSkeletons;
  60995. private _getAnimationGroups;
  60996. private _startAnimations;
  60997. /**
  60998. * Loads a glTF node.
  60999. * @param context The context when loading the asset
  61000. * @param node The glTF node property
  61001. * @param assign A function called synchronously after parsing the glTF properties
  61002. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  61003. */
  61004. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  61005. private _loadMeshAsync;
  61006. /**
  61007. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  61008. * @param context The context when loading the asset
  61009. * @param name The mesh name when loading the asset
  61010. * @param node The glTF node when loading the asset
  61011. * @param mesh The glTF mesh when loading the asset
  61012. * @param primitive The glTF mesh primitive property
  61013. * @param assign A function called synchronously after parsing the glTF properties
  61014. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  61015. */ loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  61016. private _loadVertexDataAsync;
  61017. private _createMorphTargets;
  61018. private _loadMorphTargetsAsync;
  61019. private _loadMorphTargetVertexDataAsync;
  61020. private static _LoadTransform;
  61021. private _loadSkinAsync;
  61022. private _loadBones;
  61023. private _loadBone;
  61024. private _loadSkinInverseBindMatricesDataAsync;
  61025. private _updateBoneMatrices;
  61026. private _getNodeMatrix;
  61027. /**
  61028. * Loads a glTF camera.
  61029. * @param context The context when loading the asset
  61030. * @param camera The glTF camera property
  61031. * @param assign A function called synchronously after parsing the glTF properties
  61032. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  61033. */
  61034. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  61035. private _loadAnimationsAsync;
  61036. /**
  61037. * Loads a glTF animation.
  61038. * @param context The context when loading the asset
  61039. * @param animation The glTF animation property
  61040. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  61041. */
  61042. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  61043. /**
  61044. * @hidden Loads a glTF animation channel.
  61045. * @param context The context when loading the asset
  61046. * @param animationContext The context of the animation when loading the asset
  61047. * @param animation The glTF animation property
  61048. * @param channel The glTF animation channel property
  61049. * @param babylonAnimationGroup The babylon animation group property
  61050. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  61051. * @returns A void promise when the channel load is complete
  61052. */ loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  61053. private _loadAnimationSamplerAsync;
  61054. private _loadBufferAsync;
  61055. /**
  61056. * Loads a glTF buffer view.
  61057. * @param context The context when loading the asset
  61058. * @param bufferView The glTF buffer view property
  61059. * @returns A promise that resolves with the loaded data when the load is complete
  61060. */
  61061. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  61062. private _loadIndicesAccessorAsync;
  61063. private _loadFloatAccessorAsync;
  61064. private _loadVertexBufferViewAsync;
  61065. private _loadVertexAccessorAsync;
  61066. private _loadMaterialMetallicRoughnessPropertiesAsync;
  61067. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  61068. private _createDefaultMaterial;
  61069. /**
  61070. * Creates a Babylon material from a glTF material.
  61071. * @param context The context when loading the asset
  61072. * @param material The glTF material property
  61073. * @param babylonDrawMode The draw mode for the Babylon material
  61074. * @returns The Babylon material
  61075. */
  61076. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  61077. /**
  61078. * Loads properties from a glTF material into a Babylon material.
  61079. * @param context The context when loading the asset
  61080. * @param material The glTF material property
  61081. * @param babylonMaterial The Babylon material
  61082. * @returns A promise that resolves when the load is complete
  61083. */
  61084. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  61085. /**
  61086. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  61087. * @param context The context when loading the asset
  61088. * @param material The glTF material property
  61089. * @param babylonMaterial The Babylon material
  61090. * @returns A promise that resolves when the load is complete
  61091. */
  61092. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  61093. /**
  61094. * Loads the alpha properties from a glTF material into a Babylon material.
  61095. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  61096. * @param context The context when loading the asset
  61097. * @param material The glTF material property
  61098. * @param babylonMaterial The Babylon material
  61099. */
  61100. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  61101. /**
  61102. * Loads a glTF texture info.
  61103. * @param context The context when loading the asset
  61104. * @param textureInfo The glTF texture info property
  61105. * @param assign A function called synchronously after parsing the glTF properties
  61106. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  61107. */
  61108. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  61109. private _loadTextureAsync;
  61110. private _loadSampler;
  61111. /**
  61112. * Loads a glTF image.
  61113. * @param context The context when loading the asset
  61114. * @param image The glTF image property
  61115. * @returns A promise that resolves with the loaded data when the load is complete
  61116. */
  61117. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  61118. /**
  61119. * Loads a glTF uri.
  61120. * @param context The context when loading the asset
  61121. * @param property The glTF property associated with the uri
  61122. * @param uri The base64 or relative uri
  61123. * @returns A promise that resolves with the loaded data when the load is complete
  61124. */
  61125. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  61126. private _onProgress;
  61127. /**
  61128. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  61129. * @param babylonObject the Babylon object with metadata
  61130. * @param pointer the JSON pointer
  61131. */
  61132. static AddPointerMetadata(babylonObject: {
  61133. metadata: any;
  61134. }, pointer: string): void;
  61135. private static _GetTextureWrapMode;
  61136. private static _GetTextureSamplingMode;
  61137. private static _GetTypedArray;
  61138. private static _GetNumComponents;
  61139. private static _ValidateUri;
  61140. private static _GetDrawMode;
  61141. private _compileMaterialsAsync;
  61142. private _compileShadowGeneratorsAsync;
  61143. private _forEachExtensions;
  61144. private _applyExtensions;
  61145. private _extensionsOnLoading;
  61146. private _extensionsOnReady;
  61147. private _extensionsLoadSceneAsync;
  61148. private _extensionsLoadNodeAsync;
  61149. private _extensionsLoadCameraAsync;
  61150. private _extensionsLoadVertexDataAsync;
  61151. private _extensionsLoadMeshPrimitiveAsync;
  61152. private _extensionsLoadMaterialAsync;
  61153. private _extensionsCreateMaterial;
  61154. private _extensionsLoadMaterialPropertiesAsync;
  61155. private _extensionsLoadTextureInfoAsync;
  61156. private _extensionsLoadAnimationAsync;
  61157. private _extensionsLoadSkinAsync;
  61158. private _extensionsLoadUriAsync;
  61159. /**
  61160. * Helper method called by a loader extension to load an glTF extension.
  61161. * @param context The context when loading the asset
  61162. * @param property The glTF property to load the extension from
  61163. * @param extensionName The name of the extension to load
  61164. * @param actionAsync The action to run
  61165. * @returns The promise returned by actionAsync or null if the extension does not exist
  61166. */
  61167. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  61168. /**
  61169. * Helper method called by a loader extension to load a glTF extra.
  61170. * @param context The context when loading the asset
  61171. * @param property The glTF property to load the extra from
  61172. * @param extensionName The name of the extension to load
  61173. * @param actionAsync The action to run
  61174. * @returns The promise returned by actionAsync or null if the extra does not exist
  61175. */
  61176. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  61177. /**
  61178. * Increments the indentation level and logs a message.
  61179. * @param message The message to log
  61180. */
  61181. logOpen(message: string): void;
  61182. /**
  61183. * Decrements the indentation level.
  61184. */
  61185. logClose(): void;
  61186. /**
  61187. * Logs a message
  61188. * @param message The message to log
  61189. */
  61190. log(message: string): void;
  61191. /**
  61192. * Starts a performance counter.
  61193. * @param counterName The name of the performance counter
  61194. */
  61195. startPerformanceCounter(counterName: string): void;
  61196. /**
  61197. * Ends a performance counter.
  61198. * @param counterName The name of the performance counter
  61199. */
  61200. endPerformanceCounter(counterName: string): void;
  61201. }
  61202. }
  61203. declare module BABYLON.GLTF2.Loader.Extensions {
  61204. /**
  61205. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  61206. */
  61207. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  61208. /** The name of this extension. */
  61209. readonly name: string;
  61210. /** Defines whether this extension is enabled. */
  61211. enabled: boolean;
  61212. private _loader;
  61213. private _lights?;
  61214. /** @hidden */
  61215. constructor(loader: GLTFLoader);
  61216. /** @hidden */
  61217. dispose(): void;
  61218. /** @hidden */
  61219. onLoading(): void;
  61220. /** @hidden */
  61221. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61222. private _loadLightAsync;
  61223. }
  61224. }
  61225. declare module BABYLON.GLTF2.Loader.Extensions {
  61226. /**
  61227. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  61228. */
  61229. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  61230. /** The name of this extension. */
  61231. readonly name: string;
  61232. /** The draco compression used to decode vertex data. */
  61233. dracoCompression?: DracoCompression;
  61234. /** Defines whether this extension is enabled. */
  61235. enabled: boolean;
  61236. private _loader;
  61237. private _dracoCompressionOwned;
  61238. /** @hidden */
  61239. constructor(loader: GLTFLoader);
  61240. /** @hidden */
  61241. dispose(): void;
  61242. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  61243. }
  61244. }
  61245. declare module BABYLON.GLTF2.Loader.Extensions {
  61246. /**
  61247. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  61248. */
  61249. export class KHR_lights implements IGLTFLoaderExtension {
  61250. /** The name of this extension. */
  61251. readonly name: string;
  61252. /** Defines whether this extension is enabled. */
  61253. enabled: boolean;
  61254. private _loader;
  61255. private _lights?;
  61256. /** @hidden */
  61257. constructor(loader: GLTFLoader);
  61258. /** @hidden */
  61259. dispose(): void;
  61260. /** @hidden */
  61261. onLoading(): void;
  61262. /** @hidden */
  61263. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61264. }
  61265. }
  61266. declare module BABYLON.GLTF2.Loader.Extensions {
  61267. /**
  61268. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  61269. */
  61270. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  61271. /** The name of this extension. */
  61272. readonly name: string;
  61273. /** Defines whether this extension is enabled. */
  61274. enabled: boolean;
  61275. private _loader;
  61276. /** @hidden */
  61277. constructor(loader: GLTFLoader);
  61278. /** @hidden */
  61279. dispose(): void;
  61280. /** @hidden */
  61281. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61282. private _loadSpecularGlossinessPropertiesAsync;
  61283. }
  61284. }
  61285. declare module BABYLON.GLTF2.Loader.Extensions {
  61286. /**
  61287. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  61288. */
  61289. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  61290. /** The name of this extension. */
  61291. readonly name: string;
  61292. /** Defines whether this extension is enabled. */
  61293. enabled: boolean;
  61294. private _loader;
  61295. /** @hidden */
  61296. constructor(loader: GLTFLoader);
  61297. /** @hidden */
  61298. dispose(): void;
  61299. /** @hidden */
  61300. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61301. private _loadUnlitPropertiesAsync;
  61302. }
  61303. }
  61304. declare module BABYLON.GLTF2.Loader.Extensions {
  61305. /**
  61306. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  61307. */
  61308. export class KHR_texture_transform implements IGLTFLoaderExtension {
  61309. /** The name of this extension. */
  61310. readonly name: string;
  61311. /** Defines whether this extension is enabled. */
  61312. enabled: boolean;
  61313. private _loader;
  61314. /** @hidden */
  61315. constructor(loader: GLTFLoader);
  61316. /** @hidden */
  61317. dispose(): void;
  61318. /** @hidden */
  61319. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  61320. }
  61321. }
  61322. declare module BABYLON.GLTF2.Loader.Extensions {
  61323. /**
  61324. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  61325. */
  61326. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  61327. /** The name of this extension. */
  61328. readonly name: string;
  61329. /** Defines whether this extension is enabled. */
  61330. enabled: boolean;
  61331. private _loader;
  61332. private _clips;
  61333. private _emitters;
  61334. /** @hidden */
  61335. constructor(loader: GLTFLoader);
  61336. /** @hidden */
  61337. dispose(): void;
  61338. /** @hidden */
  61339. onLoading(): void;
  61340. /** @hidden */
  61341. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61342. /** @hidden */
  61343. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61344. /** @hidden */
  61345. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  61346. private _loadClipAsync;
  61347. private _loadEmitterAsync;
  61348. private _getEventAction;
  61349. private _loadAnimationEventAsync;
  61350. }
  61351. }
  61352. declare module BABYLON.GLTF2.Loader.Extensions {
  61353. /**
  61354. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  61355. */
  61356. export class MSFT_lod implements IGLTFLoaderExtension {
  61357. /** The name of this extension. */
  61358. readonly name: string;
  61359. /** Defines whether this extension is enabled. */
  61360. enabled: boolean;
  61361. /**
  61362. * Maximum number of LODs to load, starting from the lowest LOD.
  61363. */
  61364. maxLODsToLoad: number;
  61365. /**
  61366. * Observable raised when all node LODs of one level are loaded.
  61367. * The event data is the index of the loaded LOD starting from zero.
  61368. * Dispose the loader to cancel the loading of the next level of LODs.
  61369. */
  61370. onNodeLODsLoadedObservable: Observable<number>;
  61371. /**
  61372. * Observable raised when all material LODs of one level are loaded.
  61373. * The event data is the index of the loaded LOD starting from zero.
  61374. * Dispose the loader to cancel the loading of the next level of LODs.
  61375. */
  61376. onMaterialLODsLoadedObservable: Observable<number>;
  61377. private _loader;
  61378. private _nodeIndexLOD;
  61379. private _nodeSignalLODs;
  61380. private _nodePromiseLODs;
  61381. private _materialIndexLOD;
  61382. private _materialSignalLODs;
  61383. private _materialPromiseLODs;
  61384. /** @hidden */
  61385. constructor(loader: GLTFLoader);
  61386. /** @hidden */
  61387. dispose(): void;
  61388. /** @hidden */
  61389. onReady(): void;
  61390. /** @hidden */
  61391. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61392. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  61393. /** @hidden */ loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  61394. /**
  61395. * Gets an array of LOD properties from lowest to highest.
  61396. */
  61397. private _getLODs;
  61398. private _disposeUnusedMaterials;
  61399. }
  61400. }
  61401. declare module BABYLON.GLTF2.Loader.Extensions {
  61402. /** @hidden */
  61403. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  61404. readonly name: string;
  61405. enabled: boolean;
  61406. private _loader;
  61407. constructor(loader: GLTFLoader);
  61408. dispose(): void;
  61409. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61410. }
  61411. }
  61412. declare module BABYLON.GLTF2.Loader.Extensions {
  61413. /** @hidden */
  61414. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  61415. readonly name: string;
  61416. enabled: boolean;
  61417. private _loader;
  61418. constructor(loader: GLTFLoader);
  61419. dispose(): void;
  61420. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61421. }
  61422. }
  61423. declare module BABYLON {
  61424. /**
  61425. * Class reading and parsing the MTL file bundled with the obj file.
  61426. */
  61427. export class MTLFileLoader {
  61428. /**
  61429. * All material loaded from the mtl will be set here
  61430. */
  61431. materials: StandardMaterial[];
  61432. /**
  61433. * This function will read the mtl file and create each material described inside
  61434. * This function could be improve by adding :
  61435. * -some component missing (Ni, Tf...)
  61436. * -including the specific options available
  61437. *
  61438. * @param scene defines the scene the material will be created in
  61439. * @param data defines the mtl data to parse
  61440. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  61441. */
  61442. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  61443. /**
  61444. * Gets the texture for the material.
  61445. *
  61446. * If the material is imported from input file,
  61447. * We sanitize the url to ensure it takes the textre from aside the material.
  61448. *
  61449. * @param rootUrl The root url to load from
  61450. * @param value The value stored in the mtl
  61451. * @return The Texture
  61452. */
  61453. private static _getTexture;
  61454. }
  61455. /**
  61456. * Options for loading OBJ/MTL files
  61457. */
  61458. type MeshLoadOptions = {
  61459. /**
  61460. * Defines if UVs are optimized by default during load.
  61461. */
  61462. OptimizeWithUV: boolean;
  61463. /**
  61464. * Defines custom scaling of UV coordinates of loaded meshes.
  61465. */
  61466. UVScaling: Vector2;
  61467. /**
  61468. * Invert model on y-axis (does a model scaling inversion)
  61469. */
  61470. InvertY: boolean;
  61471. /**
  61472. * Invert Y-Axis of referenced textures on load
  61473. */
  61474. InvertTextureY: boolean;
  61475. /**
  61476. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61477. */
  61478. ImportVertexColors: boolean;
  61479. /**
  61480. * Compute the normals for the model, even if normals are present in the file.
  61481. */
  61482. ComputeNormals: boolean;
  61483. /**
  61484. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61485. */
  61486. SkipMaterials: boolean;
  61487. /**
  61488. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61489. */
  61490. MaterialLoadingFailsSilently: boolean;
  61491. };
  61492. /**
  61493. * OBJ file type loader.
  61494. * This is a babylon scene loader plugin.
  61495. */
  61496. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  61497. /**
  61498. * Defines if UVs are optimized by default during load.
  61499. */
  61500. static OPTIMIZE_WITH_UV: boolean;
  61501. /**
  61502. * Invert model on y-axis (does a model scaling inversion)
  61503. */
  61504. static INVERT_Y: boolean;
  61505. /**
  61506. * Invert Y-Axis of referenced textures on load
  61507. */
  61508. static INVERT_TEXTURE_Y: boolean;
  61509. /**
  61510. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61511. */
  61512. static IMPORT_VERTEX_COLORS: boolean;
  61513. /**
  61514. * Compute the normals for the model, even if normals are present in the file.
  61515. */
  61516. static COMPUTE_NORMALS: boolean;
  61517. /**
  61518. * Defines custom scaling of UV coordinates of loaded meshes.
  61519. */
  61520. static UV_SCALING: Vector2;
  61521. /**
  61522. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61523. */
  61524. static SKIP_MATERIALS: boolean;
  61525. /**
  61526. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61527. *
  61528. * Defaults to true for backwards compatibility.
  61529. */
  61530. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  61531. /**
  61532. * Defines the name of the plugin.
  61533. */
  61534. name: string;
  61535. /**
  61536. * Defines the extension the plugin is able to load.
  61537. */
  61538. extensions: string;
  61539. /** @hidden */
  61540. obj: RegExp;
  61541. /** @hidden */
  61542. group: RegExp;
  61543. /** @hidden */
  61544. mtllib: RegExp;
  61545. /** @hidden */
  61546. usemtl: RegExp;
  61547. /** @hidden */
  61548. smooth: RegExp;
  61549. /** @hidden */
  61550. vertexPattern: RegExp;
  61551. /** @hidden */
  61552. normalPattern: RegExp;
  61553. /** @hidden */
  61554. uvPattern: RegExp;
  61555. /** @hidden */
  61556. facePattern1: RegExp;
  61557. /** @hidden */
  61558. facePattern2: RegExp;
  61559. /** @hidden */
  61560. facePattern3: RegExp;
  61561. /** @hidden */
  61562. facePattern4: RegExp;
  61563. /** @hidden */
  61564. facePattern5: RegExp;
  61565. private _meshLoadOptions;
  61566. /**
  61567. * Creates loader for .OBJ files
  61568. *
  61569. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  61570. */
  61571. constructor(meshLoadOptions?: MeshLoadOptions);
  61572. private static readonly currentMeshLoadOptions;
  61573. /**
  61574. * Calls synchronously the MTL file attached to this obj.
  61575. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  61576. * Without this function materials are not displayed in the first frame (but displayed after).
  61577. * In consequence it is impossible to get material information in your HTML file
  61578. *
  61579. * @param url The URL of the MTL file
  61580. * @param rootUrl
  61581. * @param onSuccess Callback function to be called when the MTL file is loaded
  61582. * @private
  61583. */
  61584. private _loadMTL;
  61585. /**
  61586. * Instantiates a OBJ file loader plugin.
  61587. * @returns the created plugin
  61588. */
  61589. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  61590. /**
  61591. * If the data string can be loaded directly.
  61592. *
  61593. * @param data string containing the file data
  61594. * @returns if the data can be loaded directly
  61595. */
  61596. canDirectLoad(data: string): boolean;
  61597. /**
  61598. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  61599. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  61600. * @param scene the scene the meshes should be added to
  61601. * @param data the OBJ data to load
  61602. * @param rootUrl root url to load from
  61603. * @param onProgress event that fires when loading progress has occured
  61604. * @param fileName Defines the name of the file to load
  61605. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  61606. */
  61607. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61608. meshes: AbstractMesh[];
  61609. particleSystems: IParticleSystem[];
  61610. skeletons: Skeleton[];
  61611. animationGroups: AnimationGroup[];
  61612. }>;
  61613. /**
  61614. * Imports all objects from the loaded OBJ data and adds them to the scene
  61615. * @param scene the scene the objects should be added to
  61616. * @param data the OBJ data to load
  61617. * @param rootUrl root url to load from
  61618. * @param onProgress event that fires when loading progress has occured
  61619. * @param fileName Defines the name of the file to load
  61620. * @returns a promise which completes when objects have been loaded to the scene
  61621. */
  61622. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61623. /**
  61624. * Load into an asset container.
  61625. * @param scene The scene to load into
  61626. * @param data The data to import
  61627. * @param rootUrl The root url for scene and resources
  61628. * @param onProgress The callback when the load progresses
  61629. * @param fileName Defines the name of the file to load
  61630. * @returns The loaded asset container
  61631. */
  61632. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  61633. /**
  61634. * Read the OBJ file and create an Array of meshes.
  61635. * Each mesh contains all information given by the OBJ and the MTL file.
  61636. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  61637. *
  61638. * @param meshesNames
  61639. * @param scene Scene The scene where are displayed the data
  61640. * @param data String The content of the obj file
  61641. * @param rootUrl String The path to the folder
  61642. * @returns Array<AbstractMesh>
  61643. * @private
  61644. */
  61645. private _parseSolid;
  61646. }
  61647. }
  61648. declare module BABYLON {
  61649. /**
  61650. * STL file type loader.
  61651. * This is a babylon scene loader plugin.
  61652. */
  61653. export class STLFileLoader implements ISceneLoaderPlugin {
  61654. /** @hidden */
  61655. solidPattern: RegExp;
  61656. /** @hidden */
  61657. facetsPattern: RegExp;
  61658. /** @hidden */
  61659. normalPattern: RegExp;
  61660. /** @hidden */
  61661. vertexPattern: RegExp;
  61662. /**
  61663. * Defines the name of the plugin.
  61664. */
  61665. name: string;
  61666. /**
  61667. * Defines the extensions the stl loader is able to load.
  61668. * force data to come in as an ArrayBuffer
  61669. * we'll convert to string if it looks like it's an ASCII .stl
  61670. */
  61671. extensions: ISceneLoaderPluginExtensions;
  61672. /**
  61673. * Import meshes into a scene.
  61674. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  61675. * @param scene The scene to import into
  61676. * @param data The data to import
  61677. * @param rootUrl The root url for scene and resources
  61678. * @param meshes The meshes array to import into
  61679. * @param particleSystems The particle systems array to import into
  61680. * @param skeletons The skeletons array to import into
  61681. * @param onError The callback when import fails
  61682. * @returns True if successful or false otherwise
  61683. */
  61684. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  61685. /**
  61686. * Load into a scene.
  61687. * @param scene The scene to load into
  61688. * @param data The data to import
  61689. * @param rootUrl The root url for scene and resources
  61690. * @param onError The callback when import fails
  61691. * @returns true if successful or false otherwise
  61692. */
  61693. load(scene: Scene, data: any, rootUrl: string): boolean;
  61694. /**
  61695. * Load into an asset container.
  61696. * @param scene The scene to load into
  61697. * @param data The data to import
  61698. * @param rootUrl The root url for scene and resources
  61699. * @param onError The callback when import fails
  61700. * @returns The loaded asset container
  61701. */
  61702. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  61703. private _isBinary;
  61704. private _parseBinary;
  61705. private _parseASCII;
  61706. }
  61707. }
  61708. declare module BABYLON {
  61709. /**
  61710. * Class for generating OBJ data from a Babylon scene.
  61711. */
  61712. export class OBJExport {
  61713. /**
  61714. * Exports the geometry of a Mesh array in .OBJ file format (text)
  61715. * @param mesh defines the list of meshes to serialize
  61716. * @param materials defines if materials should be exported
  61717. * @param matlibname defines the name of the associated mtl file
  61718. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  61719. * @returns the OBJ content
  61720. */
  61721. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  61722. /**
  61723. * Exports the material(s) of a mesh in .MTL file format (text)
  61724. * @param mesh defines the mesh to extract the material from
  61725. * @returns the mtl content
  61726. */
  61727. static MTL(mesh: Mesh): string;
  61728. }
  61729. }
  61730. declare module BABYLON {
  61731. /** @hidden */
  61732. export var __IGLTFExporterExtension: number;
  61733. /**
  61734. * Interface for extending the exporter
  61735. * @hidden
  61736. */
  61737. export interface IGLTFExporterExtension {
  61738. /**
  61739. * The name of this extension
  61740. */
  61741. readonly name: string;
  61742. /**
  61743. * Defines whether this extension is enabled
  61744. */
  61745. enabled: boolean;
  61746. /**
  61747. * Defines whether this extension is required
  61748. */
  61749. required: boolean;
  61750. }
  61751. }
  61752. declare module BABYLON.GLTF2.Exporter {
  61753. /** @hidden */
  61754. export var __IGLTFExporterExtensionV2: number;
  61755. /**
  61756. * Interface for a glTF exporter extension
  61757. * @hidden
  61758. */
  61759. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  61760. /**
  61761. * Define this method to modify the default behavior before exporting a texture
  61762. * @param context The context when loading the asset
  61763. * @param babylonTexture The glTF texture info property
  61764. * @param mimeType The mime-type of the generated image
  61765. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  61766. */
  61767. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  61768. /**
  61769. * Define this method to modify the default behavior when exporting texture info
  61770. * @param context The context when loading the asset
  61771. * @param meshPrimitive glTF mesh primitive
  61772. * @param babylonSubMesh Babylon submesh
  61773. * @param binaryWriter glTF serializer binary writer instance
  61774. * @returns nullable IMeshPrimitive promise
  61775. */
  61776. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  61777. /**
  61778. * Define this method to modify the default behavior when exporting a node
  61779. * @param context The context when exporting the node
  61780. * @param node glTF node
  61781. * @param babylonNode BabylonJS node
  61782. * @returns nullable INode promise
  61783. */
  61784. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  61785. /**
  61786. * Called after the exporter state changes to EXPORTING
  61787. */
  61788. onExporting?(): void;
  61789. }
  61790. }
  61791. declare module BABYLON.GLTF2.Exporter {
  61792. /**
  61793. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  61794. * @hidden
  61795. */
  61796. export class _GLTFMaterialExporter {
  61797. /**
  61798. * Represents the dielectric specular values for R, G and B
  61799. */
  61800. private static readonly _DielectricSpecular;
  61801. /**
  61802. * Allows the maximum specular power to be defined for material calculations
  61803. */
  61804. private static readonly _MaxSpecularPower;
  61805. /**
  61806. * Mapping to store textures
  61807. */
  61808. private _textureMap;
  61809. /**
  61810. * Numeric tolerance value
  61811. */
  61812. private static readonly _Epsilon;
  61813. /**
  61814. * Reference to the glTF Exporter
  61815. */
  61816. private _exporter;
  61817. constructor(exporter: _Exporter);
  61818. /**
  61819. * Specifies if two colors are approximately equal in value
  61820. * @param color1 first color to compare to
  61821. * @param color2 second color to compare to
  61822. * @param epsilon threshold value
  61823. */
  61824. private static FuzzyEquals;
  61825. /**
  61826. * Gets the materials from a Babylon scene and converts them to glTF materials
  61827. * @param scene babylonjs scene
  61828. * @param mimeType texture mime type
  61829. * @param images array of images
  61830. * @param textures array of textures
  61831. * @param materials array of materials
  61832. * @param imageData mapping of texture names to base64 textures
  61833. * @param hasTextureCoords specifies if texture coordinates are present on the material
  61834. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61835. /**
  61836. * Makes a copy of the glTF material without the texture parameters
  61837. * @param originalMaterial original glTF material
  61838. * @returns glTF material without texture parameters
  61839. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  61840. /**
  61841. * Specifies if the material has any texture parameters present
  61842. * @param material glTF Material
  61843. * @returns boolean specifying if texture parameters are present
  61844. */ hasTexturesPresent(material: IMaterial): boolean;
  61845. /**
  61846. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  61847. * @param babylonStandardMaterial
  61848. * @returns glTF Metallic Roughness Material representation
  61849. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  61850. /**
  61851. * Computes the metallic factor
  61852. * @param diffuse diffused value
  61853. * @param specular specular value
  61854. * @param oneMinusSpecularStrength one minus the specular strength
  61855. * @returns metallic value
  61856. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  61857. /**
  61858. * Gets the glTF alpha mode from the Babylon Material
  61859. * @param babylonMaterial Babylon Material
  61860. * @returns The Babylon alpha mode value
  61861. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  61862. /**
  61863. * Converts a Babylon Standard Material to a glTF Material
  61864. * @param babylonStandardMaterial BJS Standard Material
  61865. * @param mimeType mime type to use for the textures
  61866. * @param images array of glTF image interfaces
  61867. * @param textures array of glTF texture interfaces
  61868. * @param materials array of glTF material interfaces
  61869. * @param imageData map of image file name to data
  61870. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61871. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61872. /**
  61873. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61874. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  61875. * @param mimeType mime type to use for the textures
  61876. * @param images array of glTF image interfaces
  61877. * @param textures array of glTF texture interfaces
  61878. * @param materials array of glTF material interfaces
  61879. * @param imageData map of image file name to data
  61880. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61881. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61882. /**
  61883. * Converts an image typed array buffer to a base64 image
  61884. * @param buffer typed array buffer
  61885. * @param width width of the image
  61886. * @param height height of the image
  61887. * @param mimeType mimetype of the image
  61888. * @returns base64 image string
  61889. */
  61890. private _createBase64FromCanvasAsync;
  61891. /**
  61892. * Generates a white texture based on the specified width and height
  61893. * @param width width of the texture in pixels
  61894. * @param height height of the texture in pixels
  61895. * @param scene babylonjs scene
  61896. * @returns white texture
  61897. */
  61898. private _createWhiteTexture;
  61899. /**
  61900. * 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
  61901. * @param texture1 first texture to resize
  61902. * @param texture2 second texture to resize
  61903. * @param scene babylonjs scene
  61904. * @returns resized textures or null
  61905. */
  61906. private _resizeTexturesToSameDimensions;
  61907. /**
  61908. * Converts an array of pixels to a Float32Array
  61909. * Throws an error if the pixel format is not supported
  61910. * @param pixels - array buffer containing pixel values
  61911. * @returns Float32 of pixels
  61912. */
  61913. private _convertPixelArrayToFloat32;
  61914. /**
  61915. * Convert Specular Glossiness Textures to Metallic Roughness
  61916. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  61917. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  61918. * @param diffuseTexture texture used to store diffuse information
  61919. * @param specularGlossinessTexture texture used to store specular and glossiness information
  61920. * @param factors specular glossiness material factors
  61921. * @param mimeType the mime type to use for the texture
  61922. * @returns pbr metallic roughness interface or null
  61923. */
  61924. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  61925. /**
  61926. * Converts specular glossiness material properties to metallic roughness
  61927. * @param specularGlossiness interface with specular glossiness material properties
  61928. * @returns interface with metallic roughness material properties
  61929. */
  61930. private _convertSpecularGlossinessToMetallicRoughness;
  61931. /**
  61932. * Calculates the surface reflectance, independent of lighting conditions
  61933. * @param color Color source to calculate brightness from
  61934. * @returns number representing the perceived brightness, or zero if color is undefined
  61935. */
  61936. private _getPerceivedBrightness;
  61937. /**
  61938. * Returns the maximum color component value
  61939. * @param color
  61940. * @returns maximum color component value, or zero if color is null or undefined
  61941. */
  61942. private _getMaxComponent;
  61943. /**
  61944. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  61945. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61946. * @param mimeType mime type to use for the textures
  61947. * @param images array of glTF image interfaces
  61948. * @param textures array of glTF texture interfaces
  61949. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61950. * @param imageData map of image file name to data
  61951. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61952. * @returns glTF PBR Metallic Roughness factors
  61953. */
  61954. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  61955. private _getGLTFTextureSampler;
  61956. private _getGLTFTextureWrapMode;
  61957. private _getGLTFTextureWrapModesSampler;
  61958. /**
  61959. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  61960. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61961. * @param mimeType mime type to use for the textures
  61962. * @param images array of glTF image interfaces
  61963. * @param textures array of glTF texture interfaces
  61964. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61965. * @param imageData map of image file name to data
  61966. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61967. * @returns glTF PBR Metallic Roughness factors
  61968. */
  61969. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  61970. /**
  61971. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61972. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61973. * @param mimeType mime type to use for the textures
  61974. * @param images array of glTF image interfaces
  61975. * @param textures array of glTF texture interfaces
  61976. * @param materials array of glTF material interfaces
  61977. * @param imageData map of image file name to data
  61978. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61979. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61980. private setMetallicRoughnessPbrMaterial;
  61981. private getPixelsFromTexture;
  61982. /**
  61983. * Extracts a texture from a Babylon texture into file data and glTF data
  61984. * @param babylonTexture Babylon texture to extract
  61985. * @param mimeType Mime Type of the babylonTexture
  61986. * @return glTF texture info, or null if the texture format is not supported
  61987. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  61988. /**
  61989. * Builds a texture from base64 string
  61990. * @param base64Texture base64 texture string
  61991. * @param baseTextureName Name to use for the texture
  61992. * @param mimeType image mime type for the texture
  61993. * @param images array of images
  61994. * @param textures array of textures
  61995. * @param imageData map of image data
  61996. * @returns glTF texture info, or null if the texture format is not supported
  61997. */
  61998. private _getTextureInfoFromBase64;
  61999. }
  62000. }
  62001. declare module BABYLON {
  62002. /**
  62003. * Class for holding and downloading glTF file data
  62004. */
  62005. export class GLTFData {
  62006. /**
  62007. * Object which contains the file name as the key and its data as the value
  62008. */
  62009. glTFFiles: {
  62010. [fileName: string]: string | Blob;
  62011. };
  62012. /**
  62013. * Initializes the glTF file object
  62014. */
  62015. constructor();
  62016. /**
  62017. * Downloads the glTF data as files based on their names and data
  62018. */
  62019. downloadFiles(): void;
  62020. }
  62021. }
  62022. declare module BABYLON {
  62023. /**
  62024. * Holds a collection of exporter options and parameters
  62025. */
  62026. export interface IExportOptions {
  62027. /**
  62028. * Function which indicates whether a babylon node should be exported or not
  62029. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  62030. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  62031. */
  62032. shouldExportNode?(node: Node): boolean;
  62033. /**
  62034. * The sample rate to bake animation curves
  62035. */
  62036. animationSampleRate?: number;
  62037. /**
  62038. * Begin serialization without waiting for the scene to be ready
  62039. */
  62040. exportWithoutWaitingForScene?: boolean;
  62041. }
  62042. /**
  62043. * Class for generating glTF data from a Babylon scene.
  62044. */
  62045. export class GLTF2Export {
  62046. /**
  62047. * Exports the geometry of the scene to .gltf file format asynchronously
  62048. * @param scene Babylon scene with scene hierarchy information
  62049. * @param filePrefix File prefix to use when generating the glTF file
  62050. * @param options Exporter options
  62051. * @returns Returns an object with a .gltf file and associates texture names
  62052. * as keys and their data and paths as values
  62053. */
  62054. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  62055. private static _PreExportAsync;
  62056. private static _PostExportAsync;
  62057. /**
  62058. * Exports the geometry of the scene to .glb file format asychronously
  62059. * @param scene Babylon scene with scene hierarchy information
  62060. * @param filePrefix File prefix to use when generating glb file
  62061. * @param options Exporter options
  62062. * @returns Returns an object with a .glb filename as key and data as value
  62063. */
  62064. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  62065. }
  62066. }
  62067. declare module BABYLON.GLTF2.Exporter {
  62068. /**
  62069. * @hidden
  62070. */
  62071. export class _GLTFUtilities {
  62072. /**
  62073. * Creates a buffer view based on the supplied arguments
  62074. * @param bufferIndex index value of the specified buffer
  62075. * @param byteOffset byte offset value
  62076. * @param byteLength byte length of the bufferView
  62077. * @param byteStride byte distance between conequential elements
  62078. * @param name name of the buffer view
  62079. * @returns bufferView for glTF
  62080. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  62081. /**
  62082. * Creates an accessor based on the supplied arguments
  62083. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  62084. * @param name The name of the accessor
  62085. * @param type The type of the accessor
  62086. * @param componentType The datatype of components in the attribute
  62087. * @param count The number of attributes referenced by this accessor
  62088. * @param byteOffset The offset relative to the start of the bufferView in bytes
  62089. * @param min Minimum value of each component in this attribute
  62090. * @param max Maximum value of each component in this attribute
  62091. * @returns accessor for glTF
  62092. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  62093. /**
  62094. * Calculates the minimum and maximum values of an array of position floats
  62095. * @param positions Positions array of a mesh
  62096. * @param vertexStart Starting vertex offset to calculate min and max values
  62097. * @param vertexCount Number of vertices to check for min and max values
  62098. * @returns min number array and max number array
  62099. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  62100. min: number[];
  62101. max: number[];
  62102. };
  62103. /**
  62104. * Converts a new right-handed Vector3
  62105. * @param vector vector3 array
  62106. * @returns right-handed Vector3
  62107. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  62108. /**
  62109. * Converts a Vector3 to right-handed
  62110. * @param vector Vector3 to convert to right-handed
  62111. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  62112. /**
  62113. * Converts a three element number array to right-handed
  62114. * @param vector number array to convert to right-handed
  62115. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  62116. /**
  62117. * Converts a new right-handed Vector3
  62118. * @param vector vector3 array
  62119. * @returns right-handed Vector3
  62120. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  62121. /**
  62122. * Converts a Vector3 to right-handed
  62123. * @param vector Vector3 to convert to right-handed
  62124. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  62125. /**
  62126. * Converts a three element number array to right-handed
  62127. * @param vector number array to convert to right-handed
  62128. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  62129. /**
  62130. * Converts a Vector4 to right-handed
  62131. * @param vector Vector4 to convert to right-handed
  62132. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  62133. /**
  62134. * Converts a Vector4 to right-handed
  62135. * @param vector Vector4 to convert to right-handed
  62136. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  62137. /**
  62138. * Converts a Quaternion to right-handed
  62139. * @param quaternion Source quaternion to convert to right-handed
  62140. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  62141. /**
  62142. * Converts a Quaternion to right-handed
  62143. * @param quaternion Source quaternion to convert to right-handed
  62144. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  62145. }
  62146. }
  62147. declare module BABYLON.GLTF2.Exporter {
  62148. /**
  62149. * Converts Babylon Scene into glTF 2.0.
  62150. * @hidden
  62151. */
  62152. export class _Exporter {
  62153. /**
  62154. * Stores the glTF to export
  62155. */ glTF: IGLTF;
  62156. /**
  62157. * Stores all generated buffer views, which represents views into the main glTF buffer data
  62158. */ bufferViews: IBufferView[];
  62159. /**
  62160. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  62161. */ accessors: IAccessor[];
  62162. /**
  62163. * Stores all the generated nodes, which contains transform and/or mesh information per node
  62164. */
  62165. private _nodes;
  62166. /**
  62167. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  62168. */
  62169. private _scenes;
  62170. /**
  62171. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  62172. */
  62173. private _meshes;
  62174. /**
  62175. * Stores all the generated material information, which represents the appearance of each primitive
  62176. */ materials: IMaterial[]; materialMap: {
  62177. [materialID: number]: number;
  62178. };
  62179. /**
  62180. * Stores all the generated texture information, which is referenced by glTF materials
  62181. */ textures: ITexture[];
  62182. /**
  62183. * Stores all the generated image information, which is referenced by glTF textures
  62184. */ images: IImage[];
  62185. /**
  62186. * Stores all the texture samplers
  62187. */ samplers: ISampler[];
  62188. /**
  62189. * Stores all the generated animation samplers, which is referenced by glTF animations
  62190. */
  62191. /**
  62192. * Stores the animations for glTF models
  62193. */
  62194. private _animations;
  62195. /**
  62196. * Stores the total amount of bytes stored in the glTF buffer
  62197. */
  62198. private _totalByteLength;
  62199. /**
  62200. * Stores a reference to the Babylon scene containing the source geometry and material information
  62201. */ babylonScene: Scene;
  62202. /**
  62203. * Stores a map of the image data, where the key is the file name and the value
  62204. * is the image data
  62205. */ imageData: {
  62206. [fileName: string]: {
  62207. data: Uint8Array;
  62208. mimeType: ImageMimeType;
  62209. };
  62210. };
  62211. /**
  62212. * Stores a map of the unique id of a node to its index in the node array
  62213. */
  62214. private _nodeMap;
  62215. /**
  62216. * Specifies if the Babylon scene should be converted to right-handed on export
  62217. */ convertToRightHandedSystem: boolean;
  62218. /**
  62219. * Baked animation sample rate
  62220. */
  62221. private _animationSampleRate;
  62222. /**
  62223. * Callback which specifies if a node should be exported or not
  62224. */
  62225. private _shouldExportNode;
  62226. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  62227. private _extensions;
  62228. private static _ExtensionNames;
  62229. private static _ExtensionFactories;
  62230. private _applyExtensions; extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62231. private _forEachExtensions;
  62232. private _extensionsOnExporting;
  62233. /**
  62234. * Load glTF serializer extensions
  62235. */
  62236. private _loadExtensions;
  62237. /**
  62238. * Creates a glTF Exporter instance, which can accept optional exporter options
  62239. * @param babylonScene Babylon scene object
  62240. * @param options Options to modify the behavior of the exporter
  62241. */
  62242. constructor(babylonScene: Scene, options?: IExportOptions);
  62243. /**
  62244. * Registers a glTF exporter extension
  62245. * @param name Name of the extension to export
  62246. * @param factory The factory function that creates the exporter extension
  62247. */
  62248. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  62249. /**
  62250. * Un-registers an exporter extension
  62251. * @param name The name fo the exporter extension
  62252. * @returns A boolean indicating whether the extension has been un-registered
  62253. */
  62254. static UnregisterExtension(name: string): boolean;
  62255. /**
  62256. * Lazy load a local engine with premultiplied alpha set to false
  62257. */ getLocalEngine(): Engine;
  62258. private reorderIndicesBasedOnPrimitiveMode;
  62259. /**
  62260. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  62261. * clock-wise during export to glTF
  62262. * @param submesh BabylonJS submesh
  62263. * @param primitiveMode Primitive mode of the mesh
  62264. * @param sideOrientation the winding order of the submesh
  62265. * @param vertexBufferKind The type of vertex attribute
  62266. * @param meshAttributeArray The vertex attribute data
  62267. * @param byteOffset The offset to the binary data
  62268. * @param binaryWriter The binary data for the glTF file
  62269. */
  62270. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  62271. /**
  62272. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  62273. * clock-wise during export to glTF
  62274. * @param submesh BabylonJS submesh
  62275. * @param primitiveMode Primitive mode of the mesh
  62276. * @param sideOrientation the winding order of the submesh
  62277. * @param vertexBufferKind The type of vertex attribute
  62278. * @param meshAttributeArray The vertex attribute data
  62279. * @param byteOffset The offset to the binary data
  62280. * @param binaryWriter The binary data for the glTF file
  62281. */
  62282. private reorderTriangleFillMode;
  62283. /**
  62284. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  62285. * clock-wise during export to glTF
  62286. * @param submesh BabylonJS submesh
  62287. * @param primitiveMode Primitive mode of the mesh
  62288. * @param sideOrientation the winding order of the submesh
  62289. * @param vertexBufferKind The type of vertex attribute
  62290. * @param meshAttributeArray The vertex attribute data
  62291. * @param byteOffset The offset to the binary data
  62292. * @param binaryWriter The binary data for the glTF file
  62293. */
  62294. private reorderTriangleStripDrawMode;
  62295. /**
  62296. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  62297. * clock-wise during export to glTF
  62298. * @param submesh BabylonJS submesh
  62299. * @param primitiveMode Primitive mode of the mesh
  62300. * @param sideOrientation the winding order of the submesh
  62301. * @param vertexBufferKind The type of vertex attribute
  62302. * @param meshAttributeArray The vertex attribute data
  62303. * @param byteOffset The offset to the binary data
  62304. * @param binaryWriter The binary data for the glTF file
  62305. */
  62306. private reorderTriangleFanMode;
  62307. /**
  62308. * Writes the vertex attribute data to binary
  62309. * @param vertices The vertices to write to the binary writer
  62310. * @param byteOffset The offset into the binary writer to overwrite binary data
  62311. * @param vertexAttributeKind The vertex attribute type
  62312. * @param meshAttributeArray The vertex attribute data
  62313. * @param binaryWriter The writer containing the binary data
  62314. */
  62315. private writeVertexAttributeData;
  62316. /**
  62317. * Writes mesh attribute data to a data buffer
  62318. * Returns the bytelength of the data
  62319. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  62320. * @param meshAttributeArray Array containing the attribute data
  62321. * @param binaryWriter The buffer to write the binary data to
  62322. * @param indices Used to specify the order of the vertex data
  62323. */
  62324. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  62325. /**
  62326. * Generates glTF json data
  62327. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  62328. * @param glTFPrefix Text to use when prefixing a glTF file
  62329. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  62330. * @returns json data as string
  62331. */
  62332. private generateJSON;
  62333. /**
  62334. * Generates data for .gltf and .bin files based on the glTF prefix string
  62335. * @param glTFPrefix Text to use when prefixing a glTF file
  62336. * @returns GLTFData with glTF file data
  62337. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  62338. /**
  62339. * Creates a binary buffer for glTF
  62340. * @returns array buffer for binary data
  62341. */
  62342. private _generateBinaryAsync;
  62343. /**
  62344. * Pads the number to a multiple of 4
  62345. * @param num number to pad
  62346. * @returns padded number
  62347. */
  62348. private _getPadding;
  62349. /**
  62350. * Generates a glb file from the json and binary data
  62351. * Returns an object with the glb file name as the key and data as the value
  62352. * @param glTFPrefix
  62353. * @returns object with glb filename as key and data as value
  62354. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  62355. /**
  62356. * Sets the TRS for each node
  62357. * @param node glTF Node for storing the transformation data
  62358. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  62359. */
  62360. private setNodeTransformation;
  62361. private getVertexBufferFromMesh;
  62362. /**
  62363. * Creates a bufferview based on the vertices type for the Babylon mesh
  62364. * @param kind Indicates the type of vertices data
  62365. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  62366. * @param binaryWriter The buffer to write the bufferview data to
  62367. */
  62368. private createBufferViewKind;
  62369. /**
  62370. * The primitive mode of the Babylon mesh
  62371. * @param babylonMesh The BabylonJS mesh
  62372. */
  62373. private getMeshPrimitiveMode;
  62374. /**
  62375. * Sets the primitive mode of the glTF mesh primitive
  62376. * @param meshPrimitive glTF mesh primitive
  62377. * @param primitiveMode The primitive mode
  62378. */
  62379. private setPrimitiveMode;
  62380. /**
  62381. * Sets the vertex attribute accessor based of the glTF mesh primitive
  62382. * @param meshPrimitive glTF mesh primitive
  62383. * @param attributeKind vertex attribute
  62384. * @returns boolean specifying if uv coordinates are present
  62385. */
  62386. private setAttributeKind;
  62387. /**
  62388. * Sets data for the primitive attributes of each submesh
  62389. * @param mesh glTF Mesh object to store the primitive attribute information
  62390. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  62391. * @param binaryWriter Buffer to write the attribute data to
  62392. */
  62393. private setPrimitiveAttributesAsync;
  62394. /**
  62395. * Creates a glTF scene based on the array of meshes
  62396. * Returns the the total byte offset
  62397. * @param babylonScene Babylon scene to get the mesh data from
  62398. * @param binaryWriter Buffer to write binary data to
  62399. */
  62400. private createSceneAsync;
  62401. /**
  62402. * Creates a mapping of Node unique id to node index and handles animations
  62403. * @param babylonScene Babylon Scene
  62404. * @param nodes Babylon transform nodes
  62405. * @param shouldExportNode Callback specifying if a transform node should be exported
  62406. * @param binaryWriter Buffer to write binary data to
  62407. * @returns Node mapping of unique id to index
  62408. */
  62409. private createNodeMapAndAnimationsAsync;
  62410. /**
  62411. * Creates a glTF node from a Babylon mesh
  62412. * @param babylonMesh Source Babylon mesh
  62413. * @param binaryWriter Buffer for storing geometry data
  62414. * @returns glTF node
  62415. */
  62416. private createNodeAsync;
  62417. }
  62418. /**
  62419. * @hidden
  62420. *
  62421. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  62422. */
  62423. export class _BinaryWriter {
  62424. /**
  62425. * Array buffer which stores all binary data
  62426. */
  62427. private _arrayBuffer;
  62428. /**
  62429. * View of the array buffer
  62430. */
  62431. private _dataView;
  62432. /**
  62433. * byte offset of data in array buffer
  62434. */
  62435. private _byteOffset;
  62436. /**
  62437. * Initialize binary writer with an initial byte length
  62438. * @param byteLength Initial byte length of the array buffer
  62439. */
  62440. constructor(byteLength: number);
  62441. /**
  62442. * Resize the array buffer to the specified byte length
  62443. * @param byteLength
  62444. */
  62445. private resizeBuffer;
  62446. /**
  62447. * Get an array buffer with the length of the byte offset
  62448. * @returns ArrayBuffer resized to the byte offset
  62449. */
  62450. getArrayBuffer(): ArrayBuffer;
  62451. /**
  62452. * Get the byte offset of the array buffer
  62453. * @returns byte offset
  62454. */
  62455. getByteOffset(): number;
  62456. /**
  62457. * Stores an UInt8 in the array buffer
  62458. * @param entry
  62459. * @param byteOffset If defined, specifies where to set the value as an offset.
  62460. */
  62461. setUInt8(entry: number, byteOffset?: number): void;
  62462. /**
  62463. * Gets an UInt32 in the array buffer
  62464. * @param entry
  62465. * @param byteOffset If defined, specifies where to set the value as an offset.
  62466. */
  62467. getUInt32(byteOffset: number): number;
  62468. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62469. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62470. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62471. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62472. /**
  62473. * Stores a Float32 in the array buffer
  62474. * @param entry
  62475. */
  62476. setFloat32(entry: number, byteOffset?: number): void;
  62477. /**
  62478. * Stores an UInt32 in the array buffer
  62479. * @param entry
  62480. * @param byteOffset If defined, specifies where to set the value as an offset.
  62481. */
  62482. setUInt32(entry: number, byteOffset?: number): void;
  62483. }
  62484. }
  62485. declare module BABYLON.GLTF2.Exporter {
  62486. /**
  62487. * @hidden
  62488. * Interface to store animation data.
  62489. */
  62490. export interface _IAnimationData {
  62491. /**
  62492. * Keyframe data.
  62493. */
  62494. inputs: number[];
  62495. /**
  62496. * Value data.
  62497. */
  62498. outputs: number[][];
  62499. /**
  62500. * Animation interpolation data.
  62501. */
  62502. samplerInterpolation: AnimationSamplerInterpolation;
  62503. /**
  62504. * Minimum keyframe value.
  62505. */
  62506. inputsMin: number;
  62507. /**
  62508. * Maximum keyframe value.
  62509. */
  62510. inputsMax: number;
  62511. }
  62512. /**
  62513. * @hidden
  62514. */
  62515. export interface _IAnimationInfo {
  62516. /**
  62517. * The target channel for the animation
  62518. */
  62519. animationChannelTargetPath: AnimationChannelTargetPath;
  62520. /**
  62521. * The glTF accessor type for the data.
  62522. */
  62523. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  62524. /**
  62525. * Specifies if quaternions should be used.
  62526. */
  62527. useQuaternion: boolean;
  62528. }
  62529. /**
  62530. * @hidden
  62531. * Utility class for generating glTF animation data from BabylonJS.
  62532. */
  62533. export class _GLTFAnimation {
  62534. /**
  62535. * @ignore
  62536. *
  62537. * Creates glTF channel animation from BabylonJS animation.
  62538. * @param babylonTransformNode - BabylonJS mesh.
  62539. * @param animation - animation.
  62540. * @param animationChannelTargetPath - The target animation channel.
  62541. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  62542. * @param useQuaternion - Specifies if quaternions are used.
  62543. * @returns nullable IAnimationData
  62544. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  62545. private static _DeduceAnimationInfo;
  62546. /**
  62547. * @ignore
  62548. * Create node animations from the transform node animations
  62549. * @param babylonNode
  62550. * @param runtimeGLTFAnimation
  62551. * @param idleGLTFAnimations
  62552. * @param nodeMap
  62553. * @param nodes
  62554. * @param binaryWriter
  62555. * @param bufferViews
  62556. * @param accessors
  62557. * @param convertToRightHandedSystem
  62558. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  62559. [key: number]: number;
  62560. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62561. /**
  62562. * @ignore
  62563. * Create node animations from the animation groups
  62564. * @param babylonScene
  62565. * @param glTFAnimations
  62566. * @param nodeMap
  62567. * @param nodes
  62568. * @param binaryWriter
  62569. * @param bufferViews
  62570. * @param accessors
  62571. * @param convertToRightHandedSystem
  62572. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  62573. [key: number]: number;
  62574. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62575. private static AddAnimation;
  62576. /**
  62577. * Create a baked animation
  62578. * @param babylonTransformNode BabylonJS mesh
  62579. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  62580. * @param animationChannelTargetPath animation target channel
  62581. * @param minFrame minimum animation frame
  62582. * @param maxFrame maximum animation frame
  62583. * @param fps frames per second of the animation
  62584. * @param inputs input key frames of the animation
  62585. * @param outputs output key frame data of the animation
  62586. * @param convertToRightHandedSystem converts the values to right-handed
  62587. * @param useQuaternion specifies if quaternions should be used
  62588. */
  62589. private static _CreateBakedAnimation;
  62590. private static _ConvertFactorToVector3OrQuaternion;
  62591. private static _SetInterpolatedValue;
  62592. /**
  62593. * Creates linear animation from the animation key frames
  62594. * @param babylonTransformNode BabylonJS mesh
  62595. * @param animation BabylonJS animation
  62596. * @param animationChannelTargetPath The target animation channel
  62597. * @param frameDelta The difference between the last and first frame of the animation
  62598. * @param inputs Array to store the key frame times
  62599. * @param outputs Array to store the key frame data
  62600. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62601. * @param useQuaternion Specifies if quaternions are used in the animation
  62602. */
  62603. private static _CreateLinearOrStepAnimation;
  62604. /**
  62605. * Creates cubic spline animation from the animation key frames
  62606. * @param babylonTransformNode BabylonJS mesh
  62607. * @param animation BabylonJS animation
  62608. * @param animationChannelTargetPath The target animation channel
  62609. * @param frameDelta The difference between the last and first frame of the animation
  62610. * @param inputs Array to store the key frame times
  62611. * @param outputs Array to store the key frame data
  62612. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62613. * @param useQuaternion Specifies if quaternions are used in the animation
  62614. */
  62615. private static _CreateCubicSplineAnimation;
  62616. private static _GetBasePositionRotationOrScale;
  62617. /**
  62618. * Adds a key frame value
  62619. * @param keyFrame
  62620. * @param animation
  62621. * @param outputs
  62622. * @param animationChannelTargetPath
  62623. * @param basePositionRotationOrScale
  62624. * @param convertToRightHandedSystem
  62625. * @param useQuaternion
  62626. */
  62627. private static _AddKeyframeValue;
  62628. /**
  62629. * Determine the interpolation based on the key frames
  62630. * @param keyFrames
  62631. * @param animationChannelTargetPath
  62632. * @param useQuaternion
  62633. */
  62634. private static _DeduceInterpolation;
  62635. /**
  62636. * Adds an input tangent or output tangent to the output data
  62637. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  62638. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  62639. * @param outputs The animation data by keyframe
  62640. * @param animationChannelTargetPath The target animation channel
  62641. * @param interpolation The interpolation type
  62642. * @param keyFrame The key frame with the animation data
  62643. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  62644. * @param useQuaternion Specifies if quaternions are used
  62645. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  62646. */
  62647. private static AddSplineTangent;
  62648. /**
  62649. * Get the minimum and maximum key frames' frame values
  62650. * @param keyFrames animation key frames
  62651. * @returns the minimum and maximum key frame value
  62652. */
  62653. private static calculateMinMaxKeyFrames;
  62654. }
  62655. }
  62656. declare module BABYLON.GLTF2.Exporter {
  62657. /** @hidden */
  62658. export var textureTransformPixelShader: {
  62659. name: string;
  62660. shader: string;
  62661. };
  62662. }
  62663. declare module BABYLON.GLTF2.Exporter.Extensions {
  62664. /**
  62665. * @hidden
  62666. */
  62667. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  62668. /** Name of this extension */
  62669. readonly name: string;
  62670. /** Defines whether this extension is enabled */
  62671. enabled: boolean;
  62672. /** Defines whether this extension is required */
  62673. required: boolean;
  62674. /** Reference to the glTF exporter */
  62675. private _exporter;
  62676. constructor(exporter: _Exporter);
  62677. dispose(): void;
  62678. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  62679. /**
  62680. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  62681. * @param babylonTexture
  62682. * @param offset
  62683. * @param rotation
  62684. * @param scale
  62685. * @param scene
  62686. */
  62687. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  62688. }
  62689. }
  62690. declare module BABYLON.GLTF2.Exporter.Extensions {
  62691. /**
  62692. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  62693. */
  62694. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  62695. /** The name of this extension. */
  62696. readonly name: string;
  62697. /** Defines whether this extension is enabled. */
  62698. enabled: boolean;
  62699. /** Defines whether this extension is required */
  62700. required: boolean;
  62701. /** Reference to the glTF exporter */
  62702. private _exporter;
  62703. private _lights;
  62704. /** @hidden */
  62705. constructor(exporter: _Exporter);
  62706. /** @hidden */
  62707. dispose(): void;
  62708. /** @hidden */
  62709. onExporting(): void;
  62710. /**
  62711. * Define this method to modify the default behavior when exporting a node
  62712. * @param context The context when exporting the node
  62713. * @param node glTF node
  62714. * @param babylonNode BabylonJS node
  62715. * @returns nullable INode promise
  62716. */
  62717. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62718. }
  62719. }
  62720. declare module BABYLON {
  62721. /**
  62722. * Class for generating STL data from a Babylon scene.
  62723. */
  62724. export class STLExport {
  62725. /**
  62726. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  62727. * @param meshes list defines the mesh to serialize
  62728. * @param download triggers the automatic download of the file.
  62729. * @param fileName changes the downloads fileName.
  62730. * @param binary changes the STL to a binary type.
  62731. * @param isLittleEndian toggle for binary type exporter.
  62732. * @returns the STL as UTF8 string
  62733. */
  62734. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  62735. }
  62736. }
  62737. /**
  62738. * @ignoreChildren
  62739. * @ignore
  62740. */
  62741. declare module "babylonjs-gltf2interface" {
  62742. export = BABYLON.GLTF2;
  62743. }
  62744. /**
  62745. * Module for glTF 2.0 Interface
  62746. * @ignoreChildren
  62747. * @ignore
  62748. */
  62749. declare module BABYLON.GLTF2 {
  62750. /**
  62751. * The datatype of the components in the attribute
  62752. */
  62753. const enum AccessorComponentType {
  62754. /**
  62755. * Byte
  62756. */
  62757. BYTE = 5120,
  62758. /**
  62759. * Unsigned Byte
  62760. */
  62761. UNSIGNED_BYTE = 5121,
  62762. /**
  62763. * Short
  62764. */
  62765. SHORT = 5122,
  62766. /**
  62767. * Unsigned Short
  62768. */
  62769. UNSIGNED_SHORT = 5123,
  62770. /**
  62771. * Unsigned Int
  62772. */
  62773. UNSIGNED_INT = 5125,
  62774. /**
  62775. * Float
  62776. */
  62777. FLOAT = 5126,
  62778. }
  62779. /**
  62780. * Specifies if the attirbute is a scalar, vector, or matrix
  62781. */
  62782. const enum AccessorType {
  62783. /**
  62784. * Scalar
  62785. */
  62786. SCALAR = "SCALAR",
  62787. /**
  62788. * Vector2
  62789. */
  62790. VEC2 = "VEC2",
  62791. /**
  62792. * Vector3
  62793. */
  62794. VEC3 = "VEC3",
  62795. /**
  62796. * Vector4
  62797. */
  62798. VEC4 = "VEC4",
  62799. /**
  62800. * Matrix2x2
  62801. */
  62802. MAT2 = "MAT2",
  62803. /**
  62804. * Matrix3x3
  62805. */
  62806. MAT3 = "MAT3",
  62807. /**
  62808. * Matrix4x4
  62809. */
  62810. MAT4 = "MAT4",
  62811. }
  62812. /**
  62813. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62814. */
  62815. const enum AnimationChannelTargetPath {
  62816. /**
  62817. * Translation
  62818. */
  62819. TRANSLATION = "translation",
  62820. /**
  62821. * Rotation
  62822. */
  62823. ROTATION = "rotation",
  62824. /**
  62825. * Scale
  62826. */
  62827. SCALE = "scale",
  62828. /**
  62829. * Weights
  62830. */
  62831. WEIGHTS = "weights",
  62832. }
  62833. /**
  62834. * Interpolation algorithm
  62835. */
  62836. const enum AnimationSamplerInterpolation {
  62837. /**
  62838. * The animated values are linearly interpolated between keyframes
  62839. */
  62840. LINEAR = "LINEAR",
  62841. /**
  62842. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  62843. */
  62844. STEP = "STEP",
  62845. /**
  62846. * The animation's interpolation is computed using a cubic spline with specified tangents
  62847. */
  62848. CUBICSPLINE = "CUBICSPLINE",
  62849. }
  62850. /**
  62851. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62852. */
  62853. const enum CameraType {
  62854. /**
  62855. * A perspective camera containing properties to create a perspective projection matrix
  62856. */
  62857. PERSPECTIVE = "perspective",
  62858. /**
  62859. * An orthographic camera containing properties to create an orthographic projection matrix
  62860. */
  62861. ORTHOGRAPHIC = "orthographic",
  62862. }
  62863. /**
  62864. * The mime-type of the image
  62865. */
  62866. const enum ImageMimeType {
  62867. /**
  62868. * JPEG Mime-type
  62869. */
  62870. JPEG = "image/jpeg",
  62871. /**
  62872. * PNG Mime-type
  62873. */
  62874. PNG = "image/png",
  62875. }
  62876. /**
  62877. * The alpha rendering mode of the material
  62878. */
  62879. const enum MaterialAlphaMode {
  62880. /**
  62881. * The alpha value is ignored and the rendered output is fully opaque
  62882. */
  62883. OPAQUE = "OPAQUE",
  62884. /**
  62885. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  62886. */
  62887. MASK = "MASK",
  62888. /**
  62889. * 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)
  62890. */
  62891. BLEND = "BLEND",
  62892. }
  62893. /**
  62894. * The type of the primitives to render
  62895. */
  62896. const enum MeshPrimitiveMode {
  62897. /**
  62898. * Points
  62899. */
  62900. POINTS = 0,
  62901. /**
  62902. * Lines
  62903. */
  62904. LINES = 1,
  62905. /**
  62906. * Line Loop
  62907. */
  62908. LINE_LOOP = 2,
  62909. /**
  62910. * Line Strip
  62911. */
  62912. LINE_STRIP = 3,
  62913. /**
  62914. * Triangles
  62915. */
  62916. TRIANGLES = 4,
  62917. /**
  62918. * Triangle Strip
  62919. */
  62920. TRIANGLE_STRIP = 5,
  62921. /**
  62922. * Triangle Fan
  62923. */
  62924. TRIANGLE_FAN = 6,
  62925. }
  62926. /**
  62927. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  62928. */
  62929. const enum TextureMagFilter {
  62930. /**
  62931. * Nearest
  62932. */
  62933. NEAREST = 9728,
  62934. /**
  62935. * Linear
  62936. */
  62937. LINEAR = 9729,
  62938. }
  62939. /**
  62940. * Minification filter. All valid values correspond to WebGL enums
  62941. */
  62942. const enum TextureMinFilter {
  62943. /**
  62944. * Nearest
  62945. */
  62946. NEAREST = 9728,
  62947. /**
  62948. * Linear
  62949. */
  62950. LINEAR = 9729,
  62951. /**
  62952. * Nearest Mip-Map Nearest
  62953. */
  62954. NEAREST_MIPMAP_NEAREST = 9984,
  62955. /**
  62956. * Linear Mipmap Nearest
  62957. */
  62958. LINEAR_MIPMAP_NEAREST = 9985,
  62959. /**
  62960. * Nearest Mipmap Linear
  62961. */
  62962. NEAREST_MIPMAP_LINEAR = 9986,
  62963. /**
  62964. * Linear Mipmap Linear
  62965. */
  62966. LINEAR_MIPMAP_LINEAR = 9987,
  62967. }
  62968. /**
  62969. * S (U) wrapping mode. All valid values correspond to WebGL enums
  62970. */
  62971. const enum TextureWrapMode {
  62972. /**
  62973. * Clamp to Edge
  62974. */
  62975. CLAMP_TO_EDGE = 33071,
  62976. /**
  62977. * Mirrored Repeat
  62978. */
  62979. MIRRORED_REPEAT = 33648,
  62980. /**
  62981. * Repeat
  62982. */
  62983. REPEAT = 10497,
  62984. }
  62985. /**
  62986. * glTF Property
  62987. */
  62988. interface IProperty {
  62989. /**
  62990. * Dictionary object with extension-specific objects
  62991. */
  62992. extensions?: {
  62993. [key: string]: any;
  62994. };
  62995. /**
  62996. * Application-Specific data
  62997. */
  62998. extras?: any;
  62999. }
  63000. /**
  63001. * glTF Child of Root Property
  63002. */
  63003. interface IChildRootProperty extends IProperty {
  63004. /**
  63005. * The user-defined name of this object
  63006. */
  63007. name?: string;
  63008. }
  63009. /**
  63010. * Indices of those attributes that deviate from their initialization value
  63011. */
  63012. interface IAccessorSparseIndices extends IProperty {
  63013. /**
  63014. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  63015. */
  63016. bufferView: number;
  63017. /**
  63018. * The offset relative to the start of the bufferView in bytes. Must be aligned
  63019. */
  63020. byteOffset?: number;
  63021. /**
  63022. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  63023. */
  63024. componentType: AccessorComponentType;
  63025. }
  63026. /**
  63027. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  63028. */
  63029. interface IAccessorSparseValues extends IProperty {
  63030. /**
  63031. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  63032. */
  63033. bufferView: number;
  63034. /**
  63035. * The offset relative to the start of the bufferView in bytes. Must be aligned
  63036. */
  63037. byteOffset?: number;
  63038. }
  63039. /**
  63040. * Sparse storage of attributes that deviate from their initialization value
  63041. */
  63042. interface IAccessorSparse extends IProperty {
  63043. /**
  63044. * The number of attributes encoded in this sparse accessor
  63045. */
  63046. count: number;
  63047. /**
  63048. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  63049. */
  63050. indices: IAccessorSparseIndices;
  63051. /**
  63052. * 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
  63053. */
  63054. values: IAccessorSparseValues;
  63055. }
  63056. /**
  63057. * 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
  63058. */
  63059. interface IAccessor extends IChildRootProperty {
  63060. /**
  63061. * The index of the bufferview
  63062. */
  63063. bufferView?: number;
  63064. /**
  63065. * The offset relative to the start of the bufferView in bytes
  63066. */
  63067. byteOffset?: number;
  63068. /**
  63069. * The datatype of components in the attribute
  63070. */
  63071. componentType: AccessorComponentType;
  63072. /**
  63073. * Specifies whether integer data values should be normalized
  63074. */
  63075. normalized?: boolean;
  63076. /**
  63077. * The number of attributes referenced by this accessor
  63078. */
  63079. count: number;
  63080. /**
  63081. * Specifies if the attribute is a scalar, vector, or matrix
  63082. */
  63083. type: AccessorType;
  63084. /**
  63085. * Maximum value of each component in this attribute
  63086. */
  63087. max?: number[];
  63088. /**
  63089. * Minimum value of each component in this attribute
  63090. */
  63091. min?: number[];
  63092. /**
  63093. * Sparse storage of attributes that deviate from their initialization value
  63094. */
  63095. sparse?: IAccessorSparse;
  63096. }
  63097. /**
  63098. * Targets an animation's sampler at a node's property
  63099. */
  63100. interface IAnimationChannel extends IProperty {
  63101. /**
  63102. * The index of a sampler in this animation used to compute the value for the target
  63103. */
  63104. sampler: number;
  63105. /**
  63106. * The index of the node and TRS property to target
  63107. */
  63108. target: IAnimationChannelTarget;
  63109. }
  63110. /**
  63111. * The index of the node and TRS property that an animation channel targets
  63112. */
  63113. interface IAnimationChannelTarget extends IProperty {
  63114. /**
  63115. * The index of the node to target
  63116. */
  63117. node: number;
  63118. /**
  63119. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  63120. */
  63121. path: AnimationChannelTargetPath;
  63122. }
  63123. /**
  63124. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  63125. */
  63126. interface IAnimationSampler extends IProperty {
  63127. /**
  63128. * The index of an accessor containing keyframe input values, e.g., time
  63129. */
  63130. input: number;
  63131. /**
  63132. * Interpolation algorithm
  63133. */
  63134. interpolation?: AnimationSamplerInterpolation;
  63135. /**
  63136. * The index of an accessor, containing keyframe output values
  63137. */
  63138. output: number;
  63139. }
  63140. /**
  63141. * A keyframe animation
  63142. */
  63143. interface IAnimation extends IChildRootProperty {
  63144. /**
  63145. * An array of channels, each of which targets an animation's sampler at a node's property
  63146. */
  63147. channels: IAnimationChannel[];
  63148. /**
  63149. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  63150. */
  63151. samplers: IAnimationSampler[];
  63152. }
  63153. /**
  63154. * Metadata about the glTF asset
  63155. */
  63156. interface IAsset extends IChildRootProperty {
  63157. /**
  63158. * A copyright message suitable for display to credit the content creator
  63159. */
  63160. copyright?: string;
  63161. /**
  63162. * Tool that generated this glTF model. Useful for debugging
  63163. */
  63164. generator?: string;
  63165. /**
  63166. * The glTF version that this asset targets
  63167. */
  63168. version: string;
  63169. /**
  63170. * The minimum glTF version that this asset targets
  63171. */
  63172. minVersion?: string;
  63173. }
  63174. /**
  63175. * A buffer points to binary geometry, animation, or skins
  63176. */
  63177. interface IBuffer extends IChildRootProperty {
  63178. /**
  63179. * 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
  63180. */
  63181. uri?: string;
  63182. /**
  63183. * The length of the buffer in bytes
  63184. */
  63185. byteLength: number;
  63186. }
  63187. /**
  63188. * A view into a buffer generally representing a subset of the buffer
  63189. */
  63190. interface IBufferView extends IChildRootProperty {
  63191. /**
  63192. * The index of the buffer
  63193. */
  63194. buffer: number;
  63195. /**
  63196. * The offset into the buffer in bytes
  63197. */
  63198. byteOffset?: number;
  63199. /**
  63200. * The lenth of the bufferView in bytes
  63201. */
  63202. byteLength: number;
  63203. /**
  63204. * The stride, in bytes
  63205. */
  63206. byteStride?: number;
  63207. }
  63208. /**
  63209. * An orthographic camera containing properties to create an orthographic projection matrix
  63210. */
  63211. interface ICameraOrthographic extends IProperty {
  63212. /**
  63213. * The floating-point horizontal magnification of the view. Must not be zero
  63214. */
  63215. xmag: number;
  63216. /**
  63217. * The floating-point vertical magnification of the view. Must not be zero
  63218. */
  63219. ymag: number;
  63220. /**
  63221. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  63222. */
  63223. zfar: number;
  63224. /**
  63225. * The floating-point distance to the near clipping plane
  63226. */
  63227. znear: number;
  63228. }
  63229. /**
  63230. * A perspective camera containing properties to create a perspective projection matrix
  63231. */
  63232. interface ICameraPerspective extends IProperty {
  63233. /**
  63234. * The floating-point aspect ratio of the field of view
  63235. */
  63236. aspectRatio?: number;
  63237. /**
  63238. * The floating-point vertical field of view in radians
  63239. */
  63240. yfov: number;
  63241. /**
  63242. * The floating-point distance to the far clipping plane
  63243. */
  63244. zfar?: number;
  63245. /**
  63246. * The floating-point distance to the near clipping plane
  63247. */
  63248. znear: number;
  63249. }
  63250. /**
  63251. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  63252. */
  63253. interface ICamera extends IChildRootProperty {
  63254. /**
  63255. * An orthographic camera containing properties to create an orthographic projection matrix
  63256. */
  63257. orthographic?: ICameraOrthographic;
  63258. /**
  63259. * A perspective camera containing properties to create a perspective projection matrix
  63260. */
  63261. perspective?: ICameraPerspective;
  63262. /**
  63263. * Specifies if the camera uses a perspective or orthographic projection
  63264. */
  63265. type: CameraType;
  63266. }
  63267. /**
  63268. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  63269. */
  63270. interface IImage extends IChildRootProperty {
  63271. /**
  63272. * 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
  63273. */
  63274. uri?: string;
  63275. /**
  63276. * The image's MIME type
  63277. */
  63278. mimeType?: ImageMimeType;
  63279. /**
  63280. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  63281. */
  63282. bufferView?: number;
  63283. }
  63284. /**
  63285. * Material Normal Texture Info
  63286. */
  63287. interface IMaterialNormalTextureInfo extends ITextureInfo {
  63288. /**
  63289. * The scalar multiplier applied to each normal vector of the normal texture
  63290. */
  63291. scale?: number;
  63292. }
  63293. /**
  63294. * Material Occlusion Texture Info
  63295. */
  63296. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  63297. /**
  63298. * A scalar multiplier controlling the amount of occlusion applied
  63299. */
  63300. strength?: number;
  63301. }
  63302. /**
  63303. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  63304. */
  63305. interface IMaterialPbrMetallicRoughness {
  63306. /**
  63307. * The material's base color factor
  63308. */
  63309. baseColorFactor?: number[];
  63310. /**
  63311. * The base color texture
  63312. */
  63313. baseColorTexture?: ITextureInfo;
  63314. /**
  63315. * The metalness of the material
  63316. */
  63317. metallicFactor?: number;
  63318. /**
  63319. * The roughness of the material
  63320. */
  63321. roughnessFactor?: number;
  63322. /**
  63323. * The metallic-roughness texture
  63324. */
  63325. metallicRoughnessTexture?: ITextureInfo;
  63326. }
  63327. /**
  63328. * The material appearance of a primitive
  63329. */
  63330. interface IMaterial extends IChildRootProperty {
  63331. /**
  63332. * 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
  63333. */
  63334. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63335. /**
  63336. * The normal map texture
  63337. */
  63338. normalTexture?: IMaterialNormalTextureInfo;
  63339. /**
  63340. * The occlusion map texture
  63341. */
  63342. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63343. /**
  63344. * The emissive map texture
  63345. */
  63346. emissiveTexture?: ITextureInfo;
  63347. /**
  63348. * 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
  63349. */
  63350. emissiveFactor?: number[];
  63351. /**
  63352. * The alpha rendering mode of the material
  63353. */
  63354. alphaMode?: MaterialAlphaMode;
  63355. /**
  63356. * The alpha cutoff value of the material
  63357. */
  63358. alphaCutoff?: number;
  63359. /**
  63360. * Specifies whether the material is double sided
  63361. */
  63362. doubleSided?: boolean;
  63363. }
  63364. /**
  63365. * Geometry to be rendered with the given material
  63366. */
  63367. interface IMeshPrimitive extends IProperty {
  63368. /**
  63369. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  63370. */
  63371. attributes: {
  63372. [name: string]: number;
  63373. };
  63374. /**
  63375. * The index of the accessor that contains the indices
  63376. */
  63377. indices?: number;
  63378. /**
  63379. * The index of the material to apply to this primitive when rendering
  63380. */
  63381. material?: number;
  63382. /**
  63383. * The type of primitives to render. All valid values correspond to WebGL enums
  63384. */
  63385. mode?: MeshPrimitiveMode;
  63386. /**
  63387. * 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
  63388. */
  63389. targets?: {
  63390. [name: string]: number;
  63391. }[];
  63392. }
  63393. /**
  63394. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  63395. */
  63396. interface IMesh extends IChildRootProperty {
  63397. /**
  63398. * An array of primitives, each defining geometry to be rendered with a material
  63399. */
  63400. primitives: IMeshPrimitive[];
  63401. /**
  63402. * Array of weights to be applied to the Morph Targets
  63403. */
  63404. weights?: number[];
  63405. }
  63406. /**
  63407. * A node in the node hierarchy
  63408. */
  63409. interface INode extends IChildRootProperty {
  63410. /**
  63411. * The index of the camera referenced by this node
  63412. */
  63413. camera?: number;
  63414. /**
  63415. * The indices of this node's children
  63416. */
  63417. children?: number[];
  63418. /**
  63419. * The index of the skin referenced by this node
  63420. */
  63421. skin?: number;
  63422. /**
  63423. * A floating-point 4x4 transformation matrix stored in column-major order
  63424. */
  63425. matrix?: number[];
  63426. /**
  63427. * The index of the mesh in this node
  63428. */
  63429. mesh?: number;
  63430. /**
  63431. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  63432. */
  63433. rotation?: number[];
  63434. /**
  63435. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  63436. */
  63437. scale?: number[];
  63438. /**
  63439. * The node's translation along the x, y, and z axes
  63440. */
  63441. translation?: number[];
  63442. /**
  63443. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  63444. */
  63445. weights?: number[];
  63446. }
  63447. /**
  63448. * Texture sampler properties for filtering and wrapping modes
  63449. */
  63450. interface ISampler extends IChildRootProperty {
  63451. /**
  63452. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  63453. */
  63454. magFilter?: TextureMagFilter;
  63455. /**
  63456. * Minification filter. All valid values correspond to WebGL enums
  63457. */
  63458. minFilter?: TextureMinFilter;
  63459. /**
  63460. * S (U) wrapping mode. All valid values correspond to WebGL enums
  63461. */
  63462. wrapS?: TextureWrapMode;
  63463. /**
  63464. * T (V) wrapping mode. All valid values correspond to WebGL enums
  63465. */
  63466. wrapT?: TextureWrapMode;
  63467. }
  63468. /**
  63469. * The root nodes of a scene
  63470. */
  63471. interface IScene extends IChildRootProperty {
  63472. /**
  63473. * The indices of each root node
  63474. */
  63475. nodes: number[];
  63476. }
  63477. /**
  63478. * Joints and matrices defining a skin
  63479. */
  63480. interface ISkin extends IChildRootProperty {
  63481. /**
  63482. * 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
  63483. */
  63484. inverseBindMatrices?: number;
  63485. /**
  63486. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  63487. */
  63488. skeleton?: number;
  63489. /**
  63490. * 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)
  63491. */
  63492. joints: number[];
  63493. }
  63494. /**
  63495. * A texture and its sampler
  63496. */
  63497. interface ITexture extends IChildRootProperty {
  63498. /**
  63499. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  63500. */
  63501. sampler?: number;
  63502. /**
  63503. * The index of the image used by this texture
  63504. */
  63505. source: number;
  63506. }
  63507. /**
  63508. * Reference to a texture
  63509. */
  63510. interface ITextureInfo extends IProperty {
  63511. /**
  63512. * The index of the texture
  63513. */
  63514. index: number;
  63515. /**
  63516. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  63517. */
  63518. texCoord?: number;
  63519. }
  63520. /**
  63521. * The root object for a glTF asset
  63522. */
  63523. interface IGLTF extends IProperty {
  63524. /**
  63525. * An array of accessors. An accessor is a typed view into a bufferView
  63526. */
  63527. accessors?: IAccessor[];
  63528. /**
  63529. * An array of keyframe animations
  63530. */
  63531. animations?: IAnimation[];
  63532. /**
  63533. * Metadata about the glTF asset
  63534. */
  63535. asset: IAsset;
  63536. /**
  63537. * An array of buffers. A buffer points to binary geometry, animation, or skins
  63538. */
  63539. buffers?: IBuffer[];
  63540. /**
  63541. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  63542. */
  63543. bufferViews?: IBufferView[];
  63544. /**
  63545. * An array of cameras
  63546. */
  63547. cameras?: ICamera[];
  63548. /**
  63549. * Names of glTF extensions used somewhere in this asset
  63550. */
  63551. extensionsUsed?: string[];
  63552. /**
  63553. * Names of glTF extensions required to properly load this asset
  63554. */
  63555. extensionsRequired?: string[];
  63556. /**
  63557. * An array of images. An image defines data used to create a texture
  63558. */
  63559. images?: IImage[];
  63560. /**
  63561. * An array of materials. A material defines the appearance of a primitive
  63562. */
  63563. materials?: IMaterial[];
  63564. /**
  63565. * An array of meshes. A mesh is a set of primitives to be rendered
  63566. */
  63567. meshes?: IMesh[];
  63568. /**
  63569. * An array of nodes
  63570. */
  63571. nodes?: INode[];
  63572. /**
  63573. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  63574. */
  63575. samplers?: ISampler[];
  63576. /**
  63577. * The index of the default scene
  63578. */
  63579. scene?: number;
  63580. /**
  63581. * An array of scenes
  63582. */
  63583. scenes?: IScene[];
  63584. /**
  63585. * An array of skins. A skin is defined by joints and matrices
  63586. */
  63587. skins?: ISkin[];
  63588. /**
  63589. * An array of textures
  63590. */
  63591. textures?: ITexture[];
  63592. }
  63593. /**
  63594. * Interface for glTF validation results
  63595. */
  63596. interface IGLTFValidationResults {
  63597. info: {
  63598. generator: string;
  63599. hasAnimations: boolean;
  63600. hasDefaultScene: boolean;
  63601. hasMaterials: boolean;
  63602. hasMorphTargets: boolean;
  63603. hasSkins: boolean;
  63604. hasTextures: boolean;
  63605. maxAttributesUsed: number;
  63606. primitivesCount: number
  63607. };
  63608. issues: {
  63609. messages: Array<string>;
  63610. numErrors: number;
  63611. numHints: number;
  63612. numInfos: number;
  63613. numWarnings: number;
  63614. truncated: boolean
  63615. };
  63616. mimeType: string;
  63617. uri: string;
  63618. validatedAt: string;
  63619. validatorVersion: string;
  63620. }
  63621. /**
  63622. * Interface for glTF validation options
  63623. */
  63624. interface IGLTFValidationOptions {
  63625. uri?: string;
  63626. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63627. validateAccessorData?: boolean;
  63628. maxIssues?: number;
  63629. ignoredIssues?: Array<string>;
  63630. severityOverrides?: Object;
  63631. }
  63632. /**
  63633. * glTF validator object Tyyings
  63634. */
  63635. interface IGLTFValidatorTypings {
  63636. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63637. }
  63638. }
  63639. /**
  63640. * Interface for glTF validation results
  63641. */
  63642. interface IGLTFValidationResults {
  63643. info: {
  63644. generator: string;
  63645. hasAnimations: boolean;
  63646. hasDefaultScene: boolean;
  63647. hasMaterials: boolean;
  63648. hasMorphTargets: boolean;
  63649. hasSkins: boolean;
  63650. hasTextures: boolean;
  63651. maxAttributesUsed: number;
  63652. primitivesCount: number
  63653. };
  63654. issues: {
  63655. messages: Array<string>;
  63656. numErrors: number;
  63657. numHints: number;
  63658. numInfos: number;
  63659. numWarnings: number;
  63660. truncated: boolean
  63661. };
  63662. mimeType: string;
  63663. uri: string;
  63664. validatedAt: string;
  63665. validatorVersion: string;
  63666. }
  63667. /**
  63668. * Interface for glTF validation options
  63669. */
  63670. interface IGLTFValidationOptions {
  63671. uri?: string;
  63672. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63673. validateAccessorData?: boolean;
  63674. maxIssues?: number;
  63675. ignoredIssues?: Array<string>;
  63676. severityOverrides?: Object;
  63677. }
  63678. /**
  63679. * glTF validator object Tyyings
  63680. */
  63681. interface IGLTFValidatorTypings {
  63682. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63683. }
  63684. declare module BABYLON {
  63685. /** @hidden */
  63686. export var cellPixelShader: {
  63687. name: string;
  63688. shader: string;
  63689. };
  63690. }
  63691. declare module BABYLON {
  63692. /** @hidden */
  63693. export var cellVertexShader: {
  63694. name: string;
  63695. shader: string;
  63696. };
  63697. }
  63698. declare module BABYLON {
  63699. export class CellMaterial extends BABYLON.PushMaterial {
  63700. private _diffuseTexture;
  63701. diffuseTexture: BABYLON.BaseTexture;
  63702. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  63703. computeHighLevel: boolean;
  63704. private _disableLighting;
  63705. disableLighting: boolean;
  63706. private _maxSimultaneousLights;
  63707. maxSimultaneousLights: number;
  63708. private _renderId;
  63709. constructor(name: string, scene: BABYLON.Scene);
  63710. needAlphaBlending(): boolean;
  63711. needAlphaTesting(): boolean;
  63712. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63713. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63714. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63715. getAnimatables(): BABYLON.IAnimatable[];
  63716. getActiveTextures(): BABYLON.BaseTexture[];
  63717. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63718. dispose(forceDisposeEffect?: boolean): void;
  63719. getClassName(): string;
  63720. clone(name: string): CellMaterial;
  63721. serialize(): any;
  63722. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  63723. }
  63724. }
  63725. declare module BABYLON {
  63726. export class CustomShaderStructure {
  63727. FragmentStore: string;
  63728. VertexStore: string;
  63729. constructor();
  63730. }
  63731. export class ShaderSpecialParts {
  63732. constructor();
  63733. Fragment_Begin: string;
  63734. Fragment_Definitions: string;
  63735. Fragment_MainBegin: string;
  63736. Fragment_Custom_Diffuse: string;
  63737. Fragment_Before_Lights: string;
  63738. Fragment_Before_Fog: string;
  63739. Fragment_Custom_Alpha: string;
  63740. Fragment_Before_FragColor: string;
  63741. Vertex_Begin: string;
  63742. Vertex_Definitions: string;
  63743. Vertex_MainBegin: string;
  63744. Vertex_Before_PositionUpdated: string;
  63745. Vertex_Before_NormalUpdated: string;
  63746. Vertex_MainEnd: string;
  63747. }
  63748. export class CustomMaterial extends BABYLON.StandardMaterial {
  63749. static ShaderIndexer: number;
  63750. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63751. FragmentShader: string;
  63752. VertexShader: string;
  63753. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63754. ReviewUniform(name: string, arr: string[]): string[];
  63755. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  63756. constructor(name: string, scene: BABYLON.Scene);
  63757. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  63758. Fragment_Begin(shaderPart: string): CustomMaterial;
  63759. Fragment_Definitions(shaderPart: string): CustomMaterial;
  63760. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  63761. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  63762. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  63763. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  63764. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  63765. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  63766. Vertex_Begin(shaderPart: string): CustomMaterial;
  63767. Vertex_Definitions(shaderPart: string): CustomMaterial;
  63768. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  63769. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  63770. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  63771. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  63772. }
  63773. }
  63774. declare module BABYLON {
  63775. export class ShaderAlebdoParts {
  63776. constructor();
  63777. Fragment_Begin: string;
  63778. Fragment_Definitions: string;
  63779. Fragment_MainBegin: string;
  63780. Fragment_Custom_Albedo: string;
  63781. Fragment_Before_Lights: string;
  63782. Fragment_Before_Fog: string;
  63783. Fragment_Custom_Alpha: string;
  63784. Fragment_Before_FragColor: string;
  63785. Vertex_Begin: string;
  63786. Vertex_Definitions: string;
  63787. Vertex_MainBegin: string;
  63788. Vertex_Before_PositionUpdated: string;
  63789. Vertex_Before_NormalUpdated: string;
  63790. Vertex_MainEnd: string;
  63791. }
  63792. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  63793. static ShaderIndexer: number;
  63794. CustomParts: ShaderAlebdoParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63795. FragmentShader: string;
  63796. VertexShader: string;
  63797. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63798. ReviewUniform(name: string, arr: string[]): string[];
  63799. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  63800. constructor(name: string, scene: BABYLON.Scene);
  63801. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  63802. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  63803. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  63804. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  63805. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  63806. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  63807. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  63808. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  63809. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  63810. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  63811. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  63812. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  63813. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  63814. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  63815. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  63816. }
  63817. }
  63818. declare module BABYLON {
  63819. /** @hidden */
  63820. export var firePixelShader: {
  63821. name: string;
  63822. shader: string;
  63823. };
  63824. }
  63825. declare module BABYLON {
  63826. /** @hidden */
  63827. export var fireVertexShader: {
  63828. name: string;
  63829. shader: string;
  63830. };
  63831. }
  63832. declare module BABYLON {
  63833. export class FireMaterial extends BABYLON.PushMaterial {
  63834. private _diffuseTexture;
  63835. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63836. private _distortionTexture;
  63837. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63838. private _opacityTexture;
  63839. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63840. diffuseColor: BABYLON.Color3;
  63841. speed: number;
  63842. private _scaledDiffuse;
  63843. private _renderId;
  63844. private _lastTime;
  63845. constructor(name: string, scene: BABYLON.Scene);
  63846. needAlphaBlending(): boolean;
  63847. needAlphaTesting(): boolean;
  63848. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63849. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63850. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63851. getAnimatables(): BABYLON.IAnimatable[];
  63852. getActiveTextures(): BABYLON.BaseTexture[];
  63853. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63854. getClassName(): string;
  63855. dispose(forceDisposeEffect?: boolean): void;
  63856. clone(name: string): FireMaterial;
  63857. serialize(): any;
  63858. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  63859. }
  63860. }
  63861. declare module BABYLON {
  63862. /** @hidden */
  63863. export var furPixelShader: {
  63864. name: string;
  63865. shader: string;
  63866. };
  63867. }
  63868. declare module BABYLON {
  63869. /** @hidden */
  63870. export var furVertexShader: {
  63871. name: string;
  63872. shader: string;
  63873. };
  63874. }
  63875. declare module BABYLON {
  63876. export class FurMaterial extends BABYLON.PushMaterial {
  63877. private _diffuseTexture;
  63878. diffuseTexture: BABYLON.BaseTexture;
  63879. private _heightTexture;
  63880. heightTexture: BABYLON.BaseTexture;
  63881. diffuseColor: BABYLON.Color3;
  63882. furLength: number;
  63883. furAngle: number;
  63884. furColor: BABYLON.Color3;
  63885. furOffset: number;
  63886. furSpacing: number;
  63887. furGravity: BABYLON.Vector3;
  63888. furSpeed: number;
  63889. furDensity: number;
  63890. furOcclusion: number;
  63891. furTexture: BABYLON.DynamicTexture;
  63892. private _disableLighting;
  63893. disableLighting: boolean;
  63894. private _maxSimultaneousLights;
  63895. maxSimultaneousLights: number;
  63896. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  63897. private _renderId;
  63898. private _furTime;
  63899. constructor(name: string, scene: BABYLON.Scene);
  63900. furTime: number;
  63901. needAlphaBlending(): boolean;
  63902. needAlphaTesting(): boolean;
  63903. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63904. updateFur(): void;
  63905. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63906. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63907. getAnimatables(): BABYLON.IAnimatable[];
  63908. getActiveTextures(): BABYLON.BaseTexture[];
  63909. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63910. dispose(forceDisposeEffect?: boolean): void;
  63911. clone(name: string): FurMaterial;
  63912. serialize(): any;
  63913. getClassName(): string;
  63914. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  63915. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  63916. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  63917. }
  63918. }
  63919. declare module BABYLON {
  63920. /** @hidden */
  63921. export var gradientPixelShader: {
  63922. name: string;
  63923. shader: string;
  63924. };
  63925. }
  63926. declare module BABYLON {
  63927. /** @hidden */
  63928. export var gradientVertexShader: {
  63929. name: string;
  63930. shader: string;
  63931. };
  63932. }
  63933. declare module BABYLON {
  63934. export class GradientMaterial extends BABYLON.PushMaterial {
  63935. private _maxSimultaneousLights;
  63936. maxSimultaneousLights: number;
  63937. topColor: BABYLON.Color3;
  63938. topColorAlpha: number;
  63939. bottomColor: BABYLON.Color3;
  63940. bottomColorAlpha: number;
  63941. offset: number;
  63942. scale: number;
  63943. smoothness: number;
  63944. private _disableLighting;
  63945. disableLighting: boolean;
  63946. private _renderId;
  63947. constructor(name: string, scene: BABYLON.Scene);
  63948. needAlphaBlending(): boolean;
  63949. needAlphaTesting(): boolean;
  63950. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63951. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63952. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63953. getAnimatables(): BABYLON.IAnimatable[];
  63954. dispose(forceDisposeEffect?: boolean): void;
  63955. clone(name: string): GradientMaterial;
  63956. serialize(): any;
  63957. getClassName(): string;
  63958. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  63959. }
  63960. }
  63961. declare module BABYLON {
  63962. /** @hidden */
  63963. export var gridPixelShader: {
  63964. name: string;
  63965. shader: string;
  63966. };
  63967. }
  63968. declare module BABYLON {
  63969. /** @hidden */
  63970. export var gridVertexShader: {
  63971. name: string;
  63972. shader: string;
  63973. };
  63974. }
  63975. declare module BABYLON {
  63976. /**
  63977. * The grid materials allows you to wrap any shape with a grid.
  63978. * Colors are customizable.
  63979. */
  63980. export class GridMaterial extends BABYLON.PushMaterial {
  63981. /**
  63982. * Main color of the grid (e.g. between lines)
  63983. */
  63984. mainColor: BABYLON.Color3;
  63985. /**
  63986. * Color of the grid lines.
  63987. */
  63988. lineColor: BABYLON.Color3;
  63989. /**
  63990. * The scale of the grid compared to unit.
  63991. */
  63992. gridRatio: number;
  63993. /**
  63994. * Allows setting an offset for the grid lines.
  63995. */
  63996. gridOffset: BABYLON.Vector3;
  63997. /**
  63998. * The frequency of thicker lines.
  63999. */
  64000. majorUnitFrequency: number;
  64001. /**
  64002. * The visibility of minor units in the grid.
  64003. */
  64004. minorUnitVisibility: number;
  64005. /**
  64006. * The grid opacity outside of the lines.
  64007. */
  64008. opacity: number;
  64009. /**
  64010. * Determine RBG output is premultiplied by alpha value.
  64011. */
  64012. preMultiplyAlpha: boolean;
  64013. private _opacityTexture;
  64014. opacityTexture: BABYLON.BaseTexture;
  64015. private _gridControl;
  64016. private _renderId;
  64017. /**
  64018. * constructor
  64019. * @param name The name given to the material in order to identify it afterwards.
  64020. * @param scene The scene the material is used in.
  64021. */
  64022. constructor(name: string, scene: BABYLON.Scene);
  64023. /**
  64024. * Returns wehter or not the grid requires alpha blending.
  64025. */
  64026. needAlphaBlending(): boolean;
  64027. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  64028. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64029. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64030. /**
  64031. * Dispose the material and its associated resources.
  64032. * @param forceDisposeEffect will also dispose the used effect when true
  64033. */
  64034. dispose(forceDisposeEffect?: boolean): void;
  64035. clone(name: string): GridMaterial;
  64036. serialize(): any;
  64037. getClassName(): string;
  64038. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  64039. }
  64040. }
  64041. declare module BABYLON {
  64042. /** @hidden */
  64043. export var lavaPixelShader: {
  64044. name: string;
  64045. shader: string;
  64046. };
  64047. }
  64048. declare module BABYLON {
  64049. /** @hidden */
  64050. export var lavaVertexShader: {
  64051. name: string;
  64052. shader: string;
  64053. };
  64054. }
  64055. declare module BABYLON {
  64056. export class LavaMaterial extends BABYLON.PushMaterial {
  64057. private _diffuseTexture;
  64058. diffuseTexture: BABYLON.BaseTexture;
  64059. noiseTexture: BABYLON.BaseTexture;
  64060. fogColor: BABYLON.Color3;
  64061. speed: number;
  64062. movingSpeed: number;
  64063. lowFrequencySpeed: number;
  64064. fogDensity: number;
  64065. private _lastTime;
  64066. diffuseColor: BABYLON.Color3;
  64067. private _disableLighting;
  64068. disableLighting: boolean;
  64069. private _unlit;
  64070. unlit: boolean;
  64071. private _maxSimultaneousLights;
  64072. maxSimultaneousLights: number;
  64073. private _scaledDiffuse;
  64074. private _renderId;
  64075. constructor(name: string, scene: BABYLON.Scene);
  64076. needAlphaBlending(): boolean;
  64077. needAlphaTesting(): boolean;
  64078. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64079. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64080. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64081. getAnimatables(): BABYLON.IAnimatable[];
  64082. getActiveTextures(): BABYLON.BaseTexture[];
  64083. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64084. dispose(forceDisposeEffect?: boolean): void;
  64085. clone(name: string): LavaMaterial;
  64086. serialize(): any;
  64087. getClassName(): string;
  64088. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  64089. }
  64090. }
  64091. declare module BABYLON {
  64092. /** @hidden */
  64093. export var mixPixelShader: {
  64094. name: string;
  64095. shader: string;
  64096. };
  64097. }
  64098. declare module BABYLON {
  64099. /** @hidden */
  64100. export var mixVertexShader: {
  64101. name: string;
  64102. shader: string;
  64103. };
  64104. }
  64105. declare module BABYLON {
  64106. export class MixMaterial extends BABYLON.PushMaterial {
  64107. /**
  64108. * Mix textures
  64109. */
  64110. private _mixTexture1;
  64111. mixTexture1: BABYLON.BaseTexture;
  64112. private _mixTexture2;
  64113. mixTexture2: BABYLON.BaseTexture;
  64114. /**
  64115. * Diffuse textures
  64116. */
  64117. private _diffuseTexture1;
  64118. diffuseTexture1: BABYLON.Texture;
  64119. private _diffuseTexture2;
  64120. diffuseTexture2: BABYLON.Texture;
  64121. private _diffuseTexture3;
  64122. diffuseTexture3: BABYLON.Texture;
  64123. private _diffuseTexture4;
  64124. diffuseTexture4: BABYLON.Texture;
  64125. private _diffuseTexture5;
  64126. diffuseTexture5: BABYLON.Texture;
  64127. private _diffuseTexture6;
  64128. diffuseTexture6: BABYLON.Texture;
  64129. private _diffuseTexture7;
  64130. diffuseTexture7: BABYLON.Texture;
  64131. private _diffuseTexture8;
  64132. diffuseTexture8: BABYLON.Texture;
  64133. /**
  64134. * Uniforms
  64135. */
  64136. diffuseColor: BABYLON.Color3;
  64137. specularColor: BABYLON.Color3;
  64138. specularPower: number;
  64139. private _disableLighting;
  64140. disableLighting: boolean;
  64141. private _maxSimultaneousLights;
  64142. maxSimultaneousLights: number;
  64143. private _renderId;
  64144. constructor(name: string, scene: BABYLON.Scene);
  64145. needAlphaBlending(): boolean;
  64146. needAlphaTesting(): boolean;
  64147. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64148. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64149. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64150. getAnimatables(): BABYLON.IAnimatable[];
  64151. getActiveTextures(): BABYLON.BaseTexture[];
  64152. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64153. dispose(forceDisposeEffect?: boolean): void;
  64154. clone(name: string): MixMaterial;
  64155. serialize(): any;
  64156. getClassName(): string;
  64157. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  64158. }
  64159. }
  64160. declare module BABYLON {
  64161. /** @hidden */
  64162. export var normalPixelShader: {
  64163. name: string;
  64164. shader: string;
  64165. };
  64166. }
  64167. declare module BABYLON {
  64168. /** @hidden */
  64169. export var normalVertexShader: {
  64170. name: string;
  64171. shader: string;
  64172. };
  64173. }
  64174. declare module BABYLON {
  64175. export class NormalMaterial extends BABYLON.PushMaterial {
  64176. private _diffuseTexture;
  64177. diffuseTexture: BABYLON.BaseTexture;
  64178. diffuseColor: BABYLON.Color3;
  64179. private _disableLighting;
  64180. disableLighting: boolean;
  64181. private _maxSimultaneousLights;
  64182. maxSimultaneousLights: number;
  64183. private _renderId;
  64184. constructor(name: string, scene: BABYLON.Scene);
  64185. needAlphaBlending(): boolean;
  64186. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  64187. needAlphaTesting(): boolean;
  64188. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64189. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64190. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64191. getAnimatables(): BABYLON.IAnimatable[];
  64192. getActiveTextures(): BABYLON.BaseTexture[];
  64193. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64194. dispose(forceDisposeEffect?: boolean): void;
  64195. clone(name: string): NormalMaterial;
  64196. serialize(): any;
  64197. getClassName(): string;
  64198. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  64199. }
  64200. }
  64201. declare module BABYLON {
  64202. /** @hidden */
  64203. export var shadowOnlyPixelShader: {
  64204. name: string;
  64205. shader: string;
  64206. };
  64207. }
  64208. declare module BABYLON {
  64209. /** @hidden */
  64210. export var shadowOnlyVertexShader: {
  64211. name: string;
  64212. shader: string;
  64213. };
  64214. }
  64215. declare module BABYLON {
  64216. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  64217. private _renderId;
  64218. private _activeLight;
  64219. constructor(name: string, scene: BABYLON.Scene);
  64220. shadowColor: BABYLON.Color3;
  64221. needAlphaBlending(): boolean;
  64222. needAlphaTesting(): boolean;
  64223. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64224. activeLight: BABYLON.IShadowLight;
  64225. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64226. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64227. clone(name: string): ShadowOnlyMaterial;
  64228. serialize(): any;
  64229. getClassName(): string;
  64230. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  64231. }
  64232. }
  64233. declare module BABYLON {
  64234. /** @hidden */
  64235. export var simplePixelShader: {
  64236. name: string;
  64237. shader: string;
  64238. };
  64239. }
  64240. declare module BABYLON {
  64241. /** @hidden */
  64242. export var simpleVertexShader: {
  64243. name: string;
  64244. shader: string;
  64245. };
  64246. }
  64247. declare module BABYLON {
  64248. export class SimpleMaterial extends BABYLON.PushMaterial {
  64249. private _diffuseTexture;
  64250. diffuseTexture: BABYLON.BaseTexture;
  64251. diffuseColor: BABYLON.Color3;
  64252. private _disableLighting;
  64253. disableLighting: boolean;
  64254. private _maxSimultaneousLights;
  64255. maxSimultaneousLights: number;
  64256. private _renderId;
  64257. constructor(name: string, scene: BABYLON.Scene);
  64258. needAlphaBlending(): boolean;
  64259. needAlphaTesting(): boolean;
  64260. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64261. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64262. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64263. getAnimatables(): BABYLON.IAnimatable[];
  64264. getActiveTextures(): BABYLON.BaseTexture[];
  64265. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64266. dispose(forceDisposeEffect?: boolean): void;
  64267. clone(name: string): SimpleMaterial;
  64268. serialize(): any;
  64269. getClassName(): string;
  64270. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  64271. }
  64272. }
  64273. declare module BABYLON {
  64274. /** @hidden */
  64275. export var skyPixelShader: {
  64276. name: string;
  64277. shader: string;
  64278. };
  64279. }
  64280. declare module BABYLON {
  64281. /** @hidden */
  64282. export var skyVertexShader: {
  64283. name: string;
  64284. shader: string;
  64285. };
  64286. }
  64287. declare module BABYLON {
  64288. /**
  64289. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  64290. * @see https://doc.babylonjs.com/extensions/sky
  64291. */
  64292. export class SkyMaterial extends BABYLON.PushMaterial {
  64293. /**
  64294. * Defines the overall luminance of sky in interval ]0, 1[.
  64295. */
  64296. luminance: number;
  64297. /**
  64298. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  64299. */
  64300. turbidity: number;
  64301. /**
  64302. * Defines the sky appearance (light intensity).
  64303. */
  64304. rayleigh: number;
  64305. /**
  64306. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  64307. */
  64308. mieCoefficient: number;
  64309. /**
  64310. * Defines the amount of haze particles following the Mie scattering theory.
  64311. */
  64312. mieDirectionalG: number;
  64313. /**
  64314. * Defines the distance of the sun according to the active scene camera.
  64315. */
  64316. distance: number;
  64317. /**
  64318. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  64319. * "inclined".
  64320. */
  64321. inclination: number;
  64322. /**
  64323. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  64324. * an object direction and a reference direction.
  64325. */
  64326. azimuth: number;
  64327. /**
  64328. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  64329. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  64330. */
  64331. sunPosition: BABYLON.Vector3;
  64332. /**
  64333. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  64334. * .sunPosition property.
  64335. */
  64336. useSunPosition: boolean;
  64337. /**
  64338. * Defines an offset vector used to get a horizon offset.
  64339. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  64340. */
  64341. cameraOffset: BABYLON.Vector3;
  64342. private _cameraPosition;
  64343. private _renderId;
  64344. /**
  64345. * Instantiates a new sky material.
  64346. * This material allows to create dynamic and texture free
  64347. * effects for skyboxes by taking care of the atmosphere state.
  64348. * @see https://doc.babylonjs.com/extensions/sky
  64349. * @param name Define the name of the material in the scene
  64350. * @param scene Define the scene the material belong to
  64351. */
  64352. constructor(name: string, scene: BABYLON.Scene);
  64353. /**
  64354. * Specifies if the material will require alpha blending
  64355. * @returns a boolean specifying if alpha blending is needed
  64356. */
  64357. needAlphaBlending(): boolean;
  64358. /**
  64359. * Specifies if this material should be rendered in alpha test mode
  64360. * @returns false as the sky material doesn't need alpha testing.
  64361. */
  64362. needAlphaTesting(): boolean;
  64363. /**
  64364. * Get the texture used for alpha test purpose.
  64365. * @returns null as the sky material has no texture.
  64366. */
  64367. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64368. /**
  64369. * Get if the submesh is ready to be used and all its information available.
  64370. * Child classes can use it to update shaders
  64371. * @param mesh defines the mesh to check
  64372. * @param subMesh defines which submesh to check
  64373. * @param useInstances specifies that instances should be used
  64374. * @returns a boolean indicating that the submesh is ready or not
  64375. */
  64376. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64377. /**
  64378. * Binds the submesh to this material by preparing the effect and shader to draw
  64379. * @param world defines the world transformation matrix
  64380. * @param mesh defines the mesh containing the submesh
  64381. * @param subMesh defines the submesh to bind the material to
  64382. */
  64383. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64384. /**
  64385. * Get the list of animatables in the material.
  64386. * @returns the list of animatables object used in the material
  64387. */
  64388. getAnimatables(): BABYLON.IAnimatable[];
  64389. /**
  64390. * Disposes the material
  64391. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64392. */
  64393. dispose(forceDisposeEffect?: boolean): void;
  64394. /**
  64395. * Makes a duplicate of the material, and gives it a new name
  64396. * @param name defines the new name for the duplicated material
  64397. * @returns the cloned material
  64398. */
  64399. clone(name: string): SkyMaterial;
  64400. /**
  64401. * Serializes this material in a JSON representation
  64402. * @returns the serialized material object
  64403. */
  64404. serialize(): any;
  64405. /**
  64406. * Gets the current class name of the material e.g. "SkyMaterial"
  64407. * Mainly use in serialization.
  64408. * @returns the class name
  64409. */
  64410. getClassName(): string;
  64411. /**
  64412. * Creates a sky material from parsed material data
  64413. * @param source defines the JSON representation of the material
  64414. * @param scene defines the hosting scene
  64415. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64416. * @returns a new sky material
  64417. */
  64418. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  64419. }
  64420. }
  64421. declare module BABYLON {
  64422. /** @hidden */
  64423. export var terrainPixelShader: {
  64424. name: string;
  64425. shader: string;
  64426. };
  64427. }
  64428. declare module BABYLON {
  64429. /** @hidden */
  64430. export var terrainVertexShader: {
  64431. name: string;
  64432. shader: string;
  64433. };
  64434. }
  64435. declare module BABYLON {
  64436. export class TerrainMaterial extends BABYLON.PushMaterial {
  64437. private _mixTexture;
  64438. mixTexture: BABYLON.BaseTexture;
  64439. private _diffuseTexture1;
  64440. diffuseTexture1: BABYLON.Texture;
  64441. private _diffuseTexture2;
  64442. diffuseTexture2: BABYLON.Texture;
  64443. private _diffuseTexture3;
  64444. diffuseTexture3: BABYLON.Texture;
  64445. private _bumpTexture1;
  64446. bumpTexture1: BABYLON.Texture;
  64447. private _bumpTexture2;
  64448. bumpTexture2: BABYLON.Texture;
  64449. private _bumpTexture3;
  64450. bumpTexture3: BABYLON.Texture;
  64451. diffuseColor: BABYLON.Color3;
  64452. specularColor: BABYLON.Color3;
  64453. specularPower: number;
  64454. private _disableLighting;
  64455. disableLighting: boolean;
  64456. private _maxSimultaneousLights;
  64457. maxSimultaneousLights: number;
  64458. private _renderId;
  64459. constructor(name: string, scene: BABYLON.Scene);
  64460. needAlphaBlending(): boolean;
  64461. needAlphaTesting(): boolean;
  64462. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64463. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64464. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64465. getAnimatables(): BABYLON.IAnimatable[];
  64466. getActiveTextures(): BABYLON.BaseTexture[];
  64467. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64468. dispose(forceDisposeEffect?: boolean): void;
  64469. clone(name: string): TerrainMaterial;
  64470. serialize(): any;
  64471. getClassName(): string;
  64472. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  64473. }
  64474. }
  64475. declare module BABYLON {
  64476. /** @hidden */
  64477. export var triplanarPixelShader: {
  64478. name: string;
  64479. shader: string;
  64480. };
  64481. }
  64482. declare module BABYLON {
  64483. /** @hidden */
  64484. export var triplanarVertexShader: {
  64485. name: string;
  64486. shader: string;
  64487. };
  64488. }
  64489. declare module BABYLON {
  64490. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  64491. mixTexture: BABYLON.BaseTexture;
  64492. private _diffuseTextureX;
  64493. diffuseTextureX: BABYLON.BaseTexture;
  64494. private _diffuseTextureY;
  64495. diffuseTextureY: BABYLON.BaseTexture;
  64496. private _diffuseTextureZ;
  64497. diffuseTextureZ: BABYLON.BaseTexture;
  64498. private _normalTextureX;
  64499. normalTextureX: BABYLON.BaseTexture;
  64500. private _normalTextureY;
  64501. normalTextureY: BABYLON.BaseTexture;
  64502. private _normalTextureZ;
  64503. normalTextureZ: BABYLON.BaseTexture;
  64504. tileSize: number;
  64505. diffuseColor: BABYLON.Color3;
  64506. specularColor: BABYLON.Color3;
  64507. specularPower: number;
  64508. private _disableLighting;
  64509. disableLighting: boolean;
  64510. private _maxSimultaneousLights;
  64511. maxSimultaneousLights: number;
  64512. private _renderId;
  64513. constructor(name: string, scene: BABYLON.Scene);
  64514. needAlphaBlending(): boolean;
  64515. needAlphaTesting(): boolean;
  64516. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64517. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64518. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64519. getAnimatables(): BABYLON.IAnimatable[];
  64520. getActiveTextures(): BABYLON.BaseTexture[];
  64521. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64522. dispose(forceDisposeEffect?: boolean): void;
  64523. clone(name: string): TriPlanarMaterial;
  64524. serialize(): any;
  64525. getClassName(): string;
  64526. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  64527. }
  64528. }
  64529. declare module BABYLON {
  64530. /** @hidden */
  64531. export var waterPixelShader: {
  64532. name: string;
  64533. shader: string;
  64534. };
  64535. }
  64536. declare module BABYLON {
  64537. /** @hidden */
  64538. export var waterVertexShader: {
  64539. name: string;
  64540. shader: string;
  64541. };
  64542. }
  64543. declare module BABYLON {
  64544. export class WaterMaterial extends BABYLON.PushMaterial {
  64545. renderTargetSize: BABYLON.Vector2;
  64546. private _bumpTexture;
  64547. bumpTexture: BABYLON.BaseTexture;
  64548. diffuseColor: BABYLON.Color3;
  64549. specularColor: BABYLON.Color3;
  64550. specularPower: number;
  64551. private _disableLighting;
  64552. disableLighting: boolean;
  64553. private _maxSimultaneousLights;
  64554. maxSimultaneousLights: number;
  64555. /**
  64556. * @param {number}: Represents the wind force
  64557. */
  64558. windForce: number;
  64559. /**
  64560. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  64561. */
  64562. windDirection: BABYLON.Vector2;
  64563. /**
  64564. * @param {number}: Wave height, represents the height of the waves
  64565. */
  64566. waveHeight: number;
  64567. /**
  64568. * @param {number}: Bump height, represents the bump height related to the bump map
  64569. */
  64570. bumpHeight: number;
  64571. /**
  64572. * @param {boolean}: Add a smaller moving bump to less steady waves.
  64573. */
  64574. private _bumpSuperimpose;
  64575. bumpSuperimpose: boolean;
  64576. /**
  64577. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  64578. */
  64579. private _fresnelSeparate;
  64580. fresnelSeparate: boolean;
  64581. /**
  64582. * @param {boolean}: bump Waves modify the reflection.
  64583. */
  64584. private _bumpAffectsReflection;
  64585. bumpAffectsReflection: boolean;
  64586. /**
  64587. * @param {number}: The water color blended with the refraction (near)
  64588. */
  64589. waterColor: BABYLON.Color3;
  64590. /**
  64591. * @param {number}: The blend factor related to the water color
  64592. */
  64593. colorBlendFactor: number;
  64594. /**
  64595. * @param {number}: The water color blended with the reflection (far)
  64596. */
  64597. waterColor2: BABYLON.Color3;
  64598. /**
  64599. * @param {number}: The blend factor related to the water color (reflection, far)
  64600. */
  64601. colorBlendFactor2: number;
  64602. /**
  64603. * @param {number}: Represents the maximum length of a wave
  64604. */
  64605. waveLength: number;
  64606. /**
  64607. * @param {number}: Defines the waves speed
  64608. */
  64609. waveSpeed: number;
  64610. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  64611. private _mesh;
  64612. private _refractionRTT;
  64613. private _reflectionRTT;
  64614. private _reflectionTransform;
  64615. private _lastTime;
  64616. private _lastDeltaTime;
  64617. private _renderId;
  64618. private _useLogarithmicDepth;
  64619. private _waitingRenderList;
  64620. /**
  64621. * Gets a boolean indicating that current material needs to register RTT
  64622. */
  64623. readonly hasRenderTargetTextures: boolean;
  64624. /**
  64625. * Constructor
  64626. */
  64627. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  64628. useLogarithmicDepth: boolean;
  64629. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64630. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64631. addToRenderList(node: any): void;
  64632. enableRenderTargets(enable: boolean): void;
  64633. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  64634. readonly renderTargetsEnabled: boolean;
  64635. needAlphaBlending(): boolean;
  64636. needAlphaTesting(): boolean;
  64637. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64638. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64639. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64640. private _createRenderTargets;
  64641. getAnimatables(): BABYLON.IAnimatable[];
  64642. getActiveTextures(): BABYLON.BaseTexture[];
  64643. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64644. dispose(forceDisposeEffect?: boolean): void;
  64645. clone(name: string): WaterMaterial;
  64646. serialize(): any;
  64647. getClassName(): string;
  64648. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  64649. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  64650. }
  64651. }
  64652. declare module BABYLON {
  64653. /** @hidden */
  64654. export var asciiartPixelShader: {
  64655. name: string;
  64656. shader: string;
  64657. };
  64658. }
  64659. declare module BABYLON {
  64660. /**
  64661. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  64662. *
  64663. * It basically takes care rendering the font front the given font size to a texture.
  64664. * This is used later on in the postprocess.
  64665. */
  64666. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  64667. private _font;
  64668. private _text;
  64669. private _charSize;
  64670. /**
  64671. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64672. */
  64673. readonly charSize: number;
  64674. /**
  64675. * Create a new instance of the Ascii Art FontTexture class
  64676. * @param name the name of the texture
  64677. * @param font the font to use, use the W3C CSS notation
  64678. * @param text the caracter set to use in the rendering.
  64679. * @param scene the scene that owns the texture
  64680. */
  64681. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64682. /**
  64683. * Gets the max char width of a font.
  64684. * @param font the font to use, use the W3C CSS notation
  64685. * @return the max char width
  64686. */
  64687. private getFontWidth;
  64688. /**
  64689. * Gets the max char height of a font.
  64690. * @param font the font to use, use the W3C CSS notation
  64691. * @return the max char height
  64692. */
  64693. private getFontHeight;
  64694. /**
  64695. * Clones the current AsciiArtTexture.
  64696. * @return the clone of the texture.
  64697. */
  64698. clone(): AsciiArtFontTexture;
  64699. /**
  64700. * Parses a json object representing the texture and returns an instance of it.
  64701. * @param source the source JSON representation
  64702. * @param scene the scene to create the texture for
  64703. * @return the parsed texture
  64704. */
  64705. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  64706. }
  64707. /**
  64708. * Option available in the Ascii Art Post Process.
  64709. */
  64710. export interface IAsciiArtPostProcessOptions {
  64711. /**
  64712. * The font to use following the w3c font definition.
  64713. */
  64714. font?: string;
  64715. /**
  64716. * The character set to use in the postprocess.
  64717. */
  64718. characterSet?: string;
  64719. /**
  64720. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64721. * This number is defined between 0 and 1;
  64722. */
  64723. mixToTile?: number;
  64724. /**
  64725. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64726. * This number is defined between 0 and 1;
  64727. */
  64728. mixToNormal?: number;
  64729. }
  64730. /**
  64731. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  64732. *
  64733. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64734. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  64735. */
  64736. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  64737. /**
  64738. * The font texture used to render the char in the post process.
  64739. */
  64740. private _asciiArtFontTexture;
  64741. /**
  64742. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64743. * This number is defined between 0 and 1;
  64744. */
  64745. mixToTile: number;
  64746. /**
  64747. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64748. * This number is defined between 0 and 1;
  64749. */
  64750. mixToNormal: number;
  64751. /**
  64752. * Instantiates a new Ascii Art Post Process.
  64753. * @param name the name to give to the postprocess
  64754. * @camera the camera to apply the post process to.
  64755. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  64756. */
  64757. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  64758. }
  64759. }
  64760. declare module BABYLON {
  64761. /** @hidden */
  64762. export var digitalrainPixelShader: {
  64763. name: string;
  64764. shader: string;
  64765. };
  64766. }
  64767. declare module BABYLON {
  64768. /**
  64769. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  64770. *
  64771. * It basically takes care rendering the font front the given font size to a texture.
  64772. * This is used later on in the postprocess.
  64773. */
  64774. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  64775. private _font;
  64776. private _text;
  64777. private _charSize;
  64778. /**
  64779. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64780. */
  64781. readonly charSize: number;
  64782. /**
  64783. * Create a new instance of the Digital Rain FontTexture class
  64784. * @param name the name of the texture
  64785. * @param font the font to use, use the W3C CSS notation
  64786. * @param text the caracter set to use in the rendering.
  64787. * @param scene the scene that owns the texture
  64788. */
  64789. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64790. /**
  64791. * Gets the max char width of a font.
  64792. * @param font the font to use, use the W3C CSS notation
  64793. * @return the max char width
  64794. */
  64795. private getFontWidth;
  64796. /**
  64797. * Gets the max char height of a font.
  64798. * @param font the font to use, use the W3C CSS notation
  64799. * @return the max char height
  64800. */
  64801. private getFontHeight;
  64802. /**
  64803. * Clones the current DigitalRainFontTexture.
  64804. * @return the clone of the texture.
  64805. */
  64806. clone(): DigitalRainFontTexture;
  64807. /**
  64808. * Parses a json object representing the texture and returns an instance of it.
  64809. * @param source the source JSON representation
  64810. * @param scene the scene to create the texture for
  64811. * @return the parsed texture
  64812. */
  64813. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  64814. }
  64815. /**
  64816. * Option available in the Digital Rain Post Process.
  64817. */
  64818. export interface IDigitalRainPostProcessOptions {
  64819. /**
  64820. * The font to use following the w3c font definition.
  64821. */
  64822. font?: string;
  64823. /**
  64824. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64825. * This number is defined between 0 and 1;
  64826. */
  64827. mixToTile?: number;
  64828. /**
  64829. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64830. * This number is defined between 0 and 1;
  64831. */
  64832. mixToNormal?: number;
  64833. }
  64834. /**
  64835. * DigitalRainPostProcess helps rendering everithing in digital rain.
  64836. *
  64837. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64838. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  64839. */
  64840. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  64841. /**
  64842. * The font texture used to render the char in the post process.
  64843. */
  64844. private _digitalRainFontTexture;
  64845. /**
  64846. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64847. * This number is defined between 0 and 1;
  64848. */
  64849. mixToTile: number;
  64850. /**
  64851. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64852. * This number is defined between 0 and 1;
  64853. */
  64854. mixToNormal: number;
  64855. /**
  64856. * Instantiates a new Digital Rain Post Process.
  64857. * @param name the name to give to the postprocess
  64858. * @camera the camera to apply the post process to.
  64859. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  64860. */
  64861. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  64862. }
  64863. }
  64864. declare module BABYLON {
  64865. /** @hidden */
  64866. export var oceanPostProcessPixelShader: {
  64867. name: string;
  64868. shader: string;
  64869. };
  64870. }
  64871. declare module BABYLON {
  64872. /**
  64873. * Option available in the Ocean Post Process.
  64874. */
  64875. export interface IOceanPostProcessOptions {
  64876. /**
  64877. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64878. */
  64879. reflectionSize?: number | {
  64880. width: number;
  64881. height: number;
  64882. } | {
  64883. ratio: number;
  64884. };
  64885. /**
  64886. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64887. */
  64888. refractionSize?: number | {
  64889. width: number;
  64890. height: number;
  64891. } | {
  64892. ratio: number;
  64893. };
  64894. }
  64895. /**
  64896. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  64897. *
  64898. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64899. * Example usage:
  64900. * var pp = new OceanPostProcess("myOcean", camera);
  64901. * pp.reflectionEnabled = true;
  64902. * pp.refractionEnabled = true;
  64903. */
  64904. export class OceanPostProcess extends BABYLON.PostProcess {
  64905. /**
  64906. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  64907. */
  64908. /**
  64909. * Sets weither or not the real-time reflection is enabled on the ocean.
  64910. * Is set to true, the reflection mirror texture will be used as reflection texture.
  64911. */
  64912. reflectionEnabled: boolean;
  64913. /**
  64914. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  64915. */
  64916. /**
  64917. * Sets weither or not the real-time refraction is enabled on the ocean.
  64918. * Is set to true, the refraction render target texture will be used as refraction texture.
  64919. */
  64920. refractionEnabled: boolean;
  64921. /**
  64922. * Gets wether or not the post-processes is supported by the running hardware.
  64923. * This requires draw buffer supports.
  64924. */
  64925. readonly isSupported: boolean;
  64926. /**
  64927. * This is the reflection mirror texture used to display reflections on the ocean.
  64928. * By default, render list is empty.
  64929. */
  64930. reflectionTexture: BABYLON.MirrorTexture;
  64931. /**
  64932. * This is the refraction render target texture used to display refraction on the ocean.
  64933. * By default, render list is empty.
  64934. */
  64935. refractionTexture: BABYLON.RenderTargetTexture;
  64936. private _time;
  64937. private _cameraRotation;
  64938. private _cameraViewMatrix;
  64939. private _reflectionEnabled;
  64940. private _refractionEnabled;
  64941. private _geometryRenderer;
  64942. /**
  64943. * Instantiates a new Ocean Post Process.
  64944. * @param name the name to give to the postprocess.
  64945. * @camera the camera to apply the post process to.
  64946. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  64947. */
  64948. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  64949. /**
  64950. * Returns the appropriate defines according to the current configuration.
  64951. */
  64952. private _getDefines;
  64953. /**
  64954. * Computes the current camera rotation as the shader requires a camera rotation.
  64955. */
  64956. private _computeCameraRotation;
  64957. }
  64958. }
  64959. declare module BABYLON {
  64960. /** @hidden */
  64961. export var brickProceduralTexturePixelShader: {
  64962. name: string;
  64963. shader: string;
  64964. };
  64965. }
  64966. declare module BABYLON {
  64967. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  64968. private _numberOfBricksHeight;
  64969. private _numberOfBricksWidth;
  64970. private _jointColor;
  64971. private _brickColor;
  64972. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64973. updateShaderUniforms(): void;
  64974. numberOfBricksHeight: number;
  64975. numberOfBricksWidth: number;
  64976. jointColor: BABYLON.Color3;
  64977. brickColor: BABYLON.Color3;
  64978. /**
  64979. * Serializes this brick procedural texture
  64980. * @returns a serialized brick procedural texture object
  64981. */
  64982. serialize(): any;
  64983. /**
  64984. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  64985. * @param parsedTexture defines parsed texture data
  64986. * @param scene defines the current scene
  64987. * @param rootUrl defines the root URL containing brick procedural texture information
  64988. * @returns a parsed Brick Procedural BABYLON.Texture
  64989. */
  64990. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  64991. }
  64992. }
  64993. declare module BABYLON {
  64994. /** @hidden */
  64995. export var cloudProceduralTexturePixelShader: {
  64996. name: string;
  64997. shader: string;
  64998. };
  64999. }
  65000. declare module BABYLON {
  65001. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  65002. private _skyColor;
  65003. private _cloudColor;
  65004. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65005. updateShaderUniforms(): void;
  65006. skyColor: BABYLON.Color4;
  65007. cloudColor: BABYLON.Color4;
  65008. /**
  65009. * Serializes this cloud procedural texture
  65010. * @returns a serialized cloud procedural texture object
  65011. */
  65012. serialize(): any;
  65013. /**
  65014. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  65015. * @param parsedTexture defines parsed texture data
  65016. * @param scene defines the current scene
  65017. * @param rootUrl defines the root URL containing cloud procedural texture information
  65018. * @returns a parsed Cloud Procedural BABYLON.Texture
  65019. */
  65020. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  65021. }
  65022. }
  65023. declare module BABYLON {
  65024. /** @hidden */
  65025. export var fireProceduralTexturePixelShader: {
  65026. name: string;
  65027. shader: string;
  65028. };
  65029. }
  65030. declare module BABYLON {
  65031. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  65032. private _time;
  65033. private _speed;
  65034. private _autoGenerateTime;
  65035. private _fireColors;
  65036. private _alphaThreshold;
  65037. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65038. updateShaderUniforms(): void;
  65039. render(useCameraPostProcess?: boolean): void;
  65040. static readonly PurpleFireColors: BABYLON.Color3[];
  65041. static readonly GreenFireColors: BABYLON.Color3[];
  65042. static readonly RedFireColors: BABYLON.Color3[];
  65043. static readonly BlueFireColors: BABYLON.Color3[];
  65044. autoGenerateTime: boolean;
  65045. fireColors: BABYLON.Color3[];
  65046. time: number;
  65047. speed: BABYLON.Vector2;
  65048. alphaThreshold: number;
  65049. /**
  65050. * Serializes this fire procedural texture
  65051. * @returns a serialized fire procedural texture object
  65052. */
  65053. serialize(): any;
  65054. /**
  65055. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  65056. * @param parsedTexture defines parsed texture data
  65057. * @param scene defines the current scene
  65058. * @param rootUrl defines the root URL containing fire procedural texture information
  65059. * @returns a parsed Fire Procedural BABYLON.Texture
  65060. */
  65061. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  65062. }
  65063. }
  65064. declare module BABYLON {
  65065. /** @hidden */
  65066. export var grassProceduralTexturePixelShader: {
  65067. name: string;
  65068. shader: string;
  65069. };
  65070. }
  65071. declare module BABYLON {
  65072. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  65073. private _grassColors;
  65074. private _groundColor;
  65075. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65076. updateShaderUniforms(): void;
  65077. grassColors: BABYLON.Color3[];
  65078. groundColor: BABYLON.Color3;
  65079. /**
  65080. * Serializes this grass procedural texture
  65081. * @returns a serialized grass procedural texture object
  65082. */
  65083. serialize(): any;
  65084. /**
  65085. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  65086. * @param parsedTexture defines parsed texture data
  65087. * @param scene defines the current scene
  65088. * @param rootUrl defines the root URL containing grass procedural texture information
  65089. * @returns a parsed Grass Procedural BABYLON.Texture
  65090. */
  65091. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  65092. }
  65093. }
  65094. declare module BABYLON {
  65095. /** @hidden */
  65096. export var marbleProceduralTexturePixelShader: {
  65097. name: string;
  65098. shader: string;
  65099. };
  65100. }
  65101. declare module BABYLON {
  65102. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  65103. private _numberOfTilesHeight;
  65104. private _numberOfTilesWidth;
  65105. private _amplitude;
  65106. private _jointColor;
  65107. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65108. updateShaderUniforms(): void;
  65109. numberOfTilesHeight: number;
  65110. amplitude: number;
  65111. numberOfTilesWidth: number;
  65112. jointColor: BABYLON.Color3;
  65113. /**
  65114. * Serializes this marble procedural texture
  65115. * @returns a serialized marble procedural texture object
  65116. */
  65117. serialize(): any;
  65118. /**
  65119. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  65120. * @param parsedTexture defines parsed texture data
  65121. * @param scene defines the current scene
  65122. * @param rootUrl defines the root URL containing marble procedural texture information
  65123. * @returns a parsed Marble Procedural BABYLON.Texture
  65124. */
  65125. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  65126. }
  65127. }
  65128. declare module BABYLON {
  65129. /** @hidden */
  65130. export var normalMapProceduralTexturePixelShader: {
  65131. name: string;
  65132. shader: string;
  65133. };
  65134. }
  65135. declare module BABYLON {
  65136. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  65137. private _baseTexture;
  65138. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65139. updateShaderUniforms(): void;
  65140. render(useCameraPostProcess?: boolean): void;
  65141. resize(size: any, generateMipMaps: any): void;
  65142. baseTexture: BABYLON.Texture;
  65143. /**
  65144. * Serializes this normal map procedural texture
  65145. * @returns a serialized normal map procedural texture object
  65146. */
  65147. serialize(): any;
  65148. /**
  65149. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  65150. * @param parsedTexture defines parsed texture data
  65151. * @param scene defines the current scene
  65152. * @param rootUrl defines the root URL containing normal map procedural texture information
  65153. * @returns a parsed Normal Map Procedural BABYLON.Texture
  65154. */
  65155. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  65156. }
  65157. }
  65158. declare module BABYLON {
  65159. /** @hidden */
  65160. export var perlinNoiseProceduralTexturePixelShader: {
  65161. name: string;
  65162. shader: string;
  65163. };
  65164. }
  65165. declare module BABYLON {
  65166. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  65167. time: number;
  65168. timeScale: number;
  65169. translationSpeed: number;
  65170. private _currentTranslation;
  65171. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65172. updateShaderUniforms(): void;
  65173. render(useCameraPostProcess?: boolean): void;
  65174. resize(size: any, generateMipMaps: any): void;
  65175. /**
  65176. * Serializes this perlin noise procedural texture
  65177. * @returns a serialized perlin noise procedural texture object
  65178. */
  65179. serialize(): any;
  65180. /**
  65181. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  65182. * @param parsedTexture defines parsed texture data
  65183. * @param scene defines the current scene
  65184. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  65185. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  65186. */
  65187. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  65188. }
  65189. }
  65190. declare module BABYLON {
  65191. /** @hidden */
  65192. export var roadProceduralTexturePixelShader: {
  65193. name: string;
  65194. shader: string;
  65195. };
  65196. }
  65197. declare module BABYLON {
  65198. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  65199. private _roadColor;
  65200. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65201. updateShaderUniforms(): void;
  65202. roadColor: BABYLON.Color3;
  65203. /**
  65204. * Serializes this road procedural texture
  65205. * @returns a serialized road procedural texture object
  65206. */
  65207. serialize(): any;
  65208. /**
  65209. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  65210. * @param parsedTexture defines parsed texture data
  65211. * @param scene defines the current scene
  65212. * @param rootUrl defines the root URL containing road procedural texture information
  65213. * @returns a parsed Road Procedural BABYLON.Texture
  65214. */
  65215. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  65216. }
  65217. }
  65218. declare module BABYLON {
  65219. /** @hidden */
  65220. export var starfieldProceduralTexturePixelShader: {
  65221. name: string;
  65222. shader: string;
  65223. };
  65224. }
  65225. declare module BABYLON {
  65226. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  65227. private _time;
  65228. private _alpha;
  65229. private _beta;
  65230. private _zoom;
  65231. private _formuparam;
  65232. private _stepsize;
  65233. private _tile;
  65234. private _brightness;
  65235. private _darkmatter;
  65236. private _distfading;
  65237. private _saturation;
  65238. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65239. updateShaderUniforms(): void;
  65240. time: number;
  65241. alpha: number;
  65242. beta: number;
  65243. formuparam: number;
  65244. stepsize: number;
  65245. zoom: number;
  65246. tile: number;
  65247. brightness: number;
  65248. darkmatter: number;
  65249. distfading: number;
  65250. saturation: number;
  65251. /**
  65252. * Serializes this starfield procedural texture
  65253. * @returns a serialized starfield procedural texture object
  65254. */
  65255. serialize(): any;
  65256. /**
  65257. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  65258. * @param parsedTexture defines parsed texture data
  65259. * @param scene defines the current scene
  65260. * @param rootUrl defines the root URL containing startfield procedural texture information
  65261. * @returns a parsed Starfield Procedural BABYLON.Texture
  65262. */
  65263. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  65264. }
  65265. }
  65266. declare module BABYLON {
  65267. /** @hidden */
  65268. export var woodProceduralTexturePixelShader: {
  65269. name: string;
  65270. shader: string;
  65271. };
  65272. }
  65273. declare module BABYLON {
  65274. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  65275. private _ampScale;
  65276. private _woodColor;
  65277. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65278. updateShaderUniforms(): void;
  65279. ampScale: number;
  65280. woodColor: BABYLON.Color3;
  65281. /**
  65282. * Serializes this wood procedural texture
  65283. * @returns a serialized wood procedural texture object
  65284. */
  65285. serialize(): any;
  65286. /**
  65287. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  65288. * @param parsedTexture defines parsed texture data
  65289. * @param scene defines the current scene
  65290. * @param rootUrl defines the root URL containing wood procedural texture information
  65291. * @returns a parsed Wood Procedural BABYLON.Texture
  65292. */
  65293. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  65294. }
  65295. }